2016-10-27 15:52:55 +00:00
|
|
|
import { Component, OnInit} from "@angular/core";
|
2016-09-06 13:35:20 +00:00
|
|
|
import { ActivatedRoute, Params } from "@angular/router";
|
2016-10-27 15:52:55 +00:00
|
|
|
import { Location } from "@angular/common";
|
2016-09-06 12:21:25 +00:00
|
|
|
|
|
|
|
import { Duck } from "./models";
|
2016-10-27 15:52:55 +00:00
|
|
|
import { DuckService } from "./duck.service";
|
2016-09-06 12:21:25 +00:00
|
|
|
|
|
|
|
@Component({
|
2016-10-27 15:52:55 +00:00
|
|
|
moduleId: module.id,
|
2016-09-06 12:21:25 +00:00
|
|
|
selector: "duck-detail",
|
2016-10-27 15:52:55 +00:00
|
|
|
templateUrl: "duck-detail.component.html"
|
2016-09-06 12:21:25 +00:00
|
|
|
})
|
2016-10-27 15:52:55 +00:00
|
|
|
export class DuckDetailComponent {
|
|
|
|
duck: Duck;
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
private duckService: DuckService,
|
|
|
|
private route: ActivatedRoute,
|
|
|
|
private location: Location)
|
2016-09-06 13:35:20 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
this.route.params.forEach((params: Params) => {
|
|
|
|
let id = +params['id'];
|
|
|
|
this.duckService.getDuck(id)
|
|
|
|
.then(duck => this.duck = duck);
|
2016-10-27 15:52:55 +00:00
|
|
|
})
|
2016-09-06 13:35:20 +00:00
|
|
|
}
|
2016-09-06 12:21:25 +00:00
|
|
|
}
|