Skip to content

Instantly share code, notes, and snippets.

@sonicoder86
Created June 24, 2016 10:56
Show Gist options
  • Save sonicoder86/18a97e0983bc4dc0f1ba7a036500ffd5 to your computer and use it in GitHub Desktop.
Save sonicoder86/18a97e0983bc4dc0f1ba7a036500ffd5 to your computer and use it in GitHub Desktop.
Upgrading to the new Angular 2 router - part 8
// 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