Answers for "angular routers"

5

angular router

const routes: Routes = [
  { path: '',   redirectTo: '/first-component', pathMatch: 'full' }, // redirect to `first-component`
  { path: 'first-component', component: FirstComponent },
  { path: 'second-component', component: SecondComponent },
  { path: '**', component: PageNotFoundComponent },  // Wildcard route for a 404 page
];
Posted by: Guest on June-17-2021
16

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
	}
}
Posted by: Guest on May-08-2020
2

angular routing

// create a new project with routing enabled
      ng new routing-app --routing
Posted by: Guest on March-15-2021
-1

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){
   		
      }
   })
}
Posted by: Guest on March-05-2020
0

Angular route

ng generate module app-routing --flat --module=app
Posted by: Guest on August-01-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language