Modul mit Routing in Angular erzeugen
ng g m [ModuleName] --routing
Perfect Panther
ng g m [ModuleName] --routing
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
}
}
content_copy
goToItems() {
this.router.navigate(['items'], { relativeTo: this.route });
}
ng generate module app-routing --flat --module=app
//app-routing.module.ts file
const routes: Routes = [
// for simple path
{
path:'admin',component:UserHomeComponent
}
//child parent context
{
path:'',component:UserSideComponent,
children:[
{
path:'home',component:UserHomeComponent
},
{
path:'checkout',component:CheckoutComponent
}]
},
]