ng generate component Uno
ng generate component Dos
ng generate component Tres
En app.component.html:
...
<router-outlet></router-outlet>
En app.module.ts:
const appRoutes: Routes = [
{ path: '', redirectTo: 'uno', pathMatch: 'full' },
{ path: 'uno', component: UnoComponent },
{ path: 'dos', component: DosComponent },
{ path: 'tres', component: TresComponent }
];
...
imports: [
BrowserModule,
RouterModule.forRoot(appRoutes)
],
Para probarlo:
http://localhost:4200/
http://localhost:4200/uno
http://localhost:4200/dos
http://localhost:4200/tres
angular4 routing
ResponderEliminar