Created
June 24, 2016 10:56
-
-
Save sonicoder86/18a97e0983bc4dc0f1ba7a036500ffd5 to your computer and use it in GitHub Desktop.
Upgrading to the new Angular 2 router - part 8
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
// components/hero-detail/hero-detail.component.ts | |
import { Component, OnInit } from '@angular/core'; | |
import { RouteParams } from '@angular/router-deprected'; | |
import { HeroService } from '../../services/hero/hero.service' | |
@Component({ ... }) | |
export class HeroDetailComponent implements OnInit { | |
constructor(private params: RouteParams, private heroService: HeroService) {} | |
ngOnInit() { | |
this.heroService.getHero( | |
this.params.get('id') | |
).subscribe(hero => this.hero = hero); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment