Created
July 12, 2016 21:29
-
-
Save shurane/ffe0ad46303466f1265ae5a24846edb7 to your computer and use it in GitHub Desktop.
angular 2 tutorial troubles - part 5 - routing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; | |
import { ROUTER_DIRECTIVES } from '@angular/router'; | |
import { HeroService } from './hero.service'; | |
@Component({ | |
selector: 'my-app', | |
template: ` | |
<h1>{{title}}</h1> | |
<a [routerLink]="['/heroes']">Heroes</a> | |
<router-outlet></router-outlet> | |
`, | |
directives: [ROUTER_DIRECTIVES], | |
providers: [HeroService] | |
}) | |
export class AppComponent { | |
title = 'Tour of Heroes'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { provideRouter, RouterConfig } from '@angular/router'; | |
import { HeroesComponent } from './heroes.component'; | |
const routes: RouterConfig = [ | |
{ | |
path: 'heroes', | |
component: HeroesComponent | |
} | |
]; | |
export const APP_ROUTER_PROVIDERS = [ | |
provideRouter(routes) | |
]; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { bootstrap } from '@angular/platform-browser-dynamic'; | |
import { AppComponent } from './app.component'; | |
import { APP_ROUTER_PROVIDERS } from './app.routes'; | |
bootstrap(AppComponent, [ | |
APP_ROUTER_PROVIDERS | |
]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment