angular router-outlet 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 create app.routing.module.ts in angular 6
ng generate module app-routing --flat --module=app
Example 3: home page routing in angular
const routes: Routes = [
{ path: 'home_page_path', component: HomePageComponent }
];
add this in app routing file
Example 4: 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 5: angular router outlet
<router-outlet></router-outlet>
<router-outlet name='left'></router-outlet>
<router-outlet name='right'></router-outlet>