default routing in angular code example
Example 1: set default route angular
{path:'',redirectTo:'login', pathMatch: 'full' },
Example 2: angular navigate using component
import {Router} from '@angular/router'; // import router from angular router
export class Component{ // Example component..
constructor(private route:Router){}
go(){
this.route.navigate(['/page']); // navigate to other page
}
}
Example 3: how to add changes every time you route navigate to page in angular
// Place import at the top
import { Router,NavigationStart} from '@angular/router';
//Place the code below inside your class
constructor(private router: Router){}
ngOnInit(){
this.router.events.subscribe(event =>{
if (event instanceof NavigationStart){
}
})
}