Skip to content

Instantly share code, notes, and snippets.

@sonicoder86
Last active June 24, 2016 06:52
Show Gist options
  • Save sonicoder86/f6327294620a8edd1b8b80df7723d111 to your computer and use it in GitHub Desktop.
Save sonicoder86/f6327294620a8edd1b8b80df7723d111 to your computer and use it in GitHub Desktop.
Upgrading to the new Angular 2 router - part 1
// components/app/app.component.ts
import { Component } from '@angular/core';
import { RouteConfig, ROUTER_DIRECTIVES } from '@angular/router-deprected';
import { HeroesComponent } from './components/heroes/heroes.component';
import { HeroDetailComponent } from '../hero-detail/hero-detail.component';
@RouteConfig([
{
path: '/',
name: 'Heroes',
component: HeroesComponent,
useAsDefault: true
},
{
path: '/detail/:id',
name: 'HeroDetail',
component: HeroDetailComponent
}
])
@Component({
selector: 'hero-app',
template: '<router-outlet></router-outlet>',
directives: [ROUTER_DIRECTIVES]
})
export class AppComponent {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment