angular routing from one component to another code example
Example 1: angular navigate using component
import {Router} from '@angular/router';
export class Component{
constructor(private route:Router){}
go(){
this.route.navigate(['/page']);
}
}
Example 2: how to add changes every time you route navigate to page in angular
import { Router,NavigationStart} from '@angular/router';
constructor(private router: Router){}
ngOnInit(){
this.router.events.subscribe(event =>{
if (event instanceof NavigationStart){
}
})
}
Example 3: this.router.navigate
<a [routerLink]="['/', 'red-pill', {x: 'white-rabbit'}, 'neo']">
Param!
</a>