Angular: append query parameters to URL

This could be achieved by using the Router class: Using a component: import { Router, ActivatedRoute } from ‘@angular/router’; @Component({}) export class FooComponent { constructor( private _route: ActivatedRoute, private _router: Router ){} navigateToFoo(){ // changes the route without moving from the current view or // triggering a navigation event, this._router.navigate([], { relativeTo: this._route, queryParams: { … Read more

How do I navigate to a sibling route?

If you are using the new router (3.0.0-beta2), you can use the ActivatedRoute to navigate to relative path as follow: constructor(private router: Router, private r:ActivatedRoute) {} /// // DOES NOT WORK SEE UPDATE goToContact() { this.router.navigate([“../contacts”], { relativeTo: this.r }); } Update 08/02/2019 Angular 7.1.0 current route: /department/7/employees/45/sales the old version will do: /department/7/employees/45/sales/contacts As … Read more

What is the difference between ActivatedRoute and ActivatedRouteSnapshot in Angular4

Since ActivatedRoute can be reused, ActivatedRouteSnapshot is an immutable object representing a particular version of ActivatedRoute. It exposes all the same properties as ActivatedRoute as plain values, while ActivatedRoute exposes them as observables. Here is the comment in the implementation: export class ActivatedRoute { /** The current snapshot of this route */ snapshot: ActivatedRouteSnapshot; If … Read more

Do I have to unsubscribe from ActivatedRoute (e.g. params) observables?

No From the docs : When subscribing to an observable in a component, you almost always arrange to unsubscribe when the component is destroyed. There are a few exceptional observables where this is not necessary. The ActivatedRoute observables are among the exceptions. The ActivatedRoute and its observables are insulated from the Router itself. The Router … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)