Angular - Add Dashborad
Angular - Add Dashborad
Routing makes more sense when your application has more than one
view, yet the Tour of Heroes application has only the heroes view.
declares it in AppModule .
src/app/dashboard/dashboard.component.html src/app/dashboard/dashboard.comp
Top Heroes
class="heroes-menu"
*ngFor="let hero of heroes"
{{hero.name}}
src/app/dashboard/dashboard.component.ts
getHeroes(): {
.heroService.getHeroes()
.subscribe(heroes => .heroes =
heroes.slice(1, 5));
}
{ } '.∕dashboard
∕dashboard.component';
DashboardComponent .
src/app/app-routing.module.ts
site's root. That doesn't match any existing route so the router doesn't
src/app/app-routing.module.ts
This route redirects a URL that fully matches the empty path to the route
src/app/app.component.html
{{title}}
routerLink="∕dashboard" Dashboard
routerLink="∕heroes" Heroes
After the browser refreshes you can navigate freely between the two
HeroesComponent
3. By pasting a "deep link" URL into the browser address bar that
identi�es the hero to display.
view with the hero detail view. The heroes list view should no longer
Clicking a hero item now does nothing. You can �x that after you enable
{ } '.∕hero-detail
∕hero-detail.component';
Then add a parameterized route to the routes array that matches the
src/app/app-routing.module.ts
routes: = [
{ path: '', redirectTo: '∕dashboard', pathMatch:
'full' },
{ path: 'dashboard', component:
},
{ path: 'detail∕:id', component:
},
{ path: 'heroes', component: }
];