duck-booking-tool-front/app/duck-detail.component.ts
Gergely Polonkai 29a0eb7f33 Move to using routers
Signed-off-by: Gergely Polonkai <gergely@polonkai.eu>
2016-09-09 14:42:14 +02:00

32 lines
766 B
TypeScript

import { Component, Input, OnInit } from "@angular/core";
import { ActivatedRoute, Params } from "@angular/router";
import { DuckService } from "./duck.service";
import { Duck } from "./models";
@Component({
selector: "duck-detail",
templateUrl: "/app/duck-detail.component.html"
})
export class DuckDetailComponent implements OnInit {
constructor(private duckService: DuckService,
private route: ActivatedRoute)
{}
ngOnInit(): void {
this.route.params.forEach((params: Params) => {
let id = +params['id'];
this.duckService.getDuck(id)
.then(duck => this.duck = duck);
});
}
goBack(): void {
window.history.back();
}
@Input()
duck: Duck;
}