-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathitem-detail.component.ts
44 lines (35 loc) · 1.13 KB
/
item-detail.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { Component, OnInit } from "@angular/core";
import { ActivatedRoute } from "@angular/router";
import { RouterExtensions } from "nativescript-angular/router";
import { Item } from "./item";
import { ItemService } from "./item.service";
import "rxjs/add/operator/map";
@Component({
selector: "ns-details",
moduleId: module.id,
templateUrl: "./item-detail.component.html",
})
export class ItemDetailComponent implements OnInit {
item: Item;
constructor(
private itemService: ItemService,
private route: ActivatedRoute, private routerExtensions: RouterExtensions
) { }
ngOnInit(): void {
// const id = +this.route.snapshot.params["id"];
// this.item = this.itemService.getItem(id);
this.route.params
.map(params => this.itemService.getItem(+params["id"]))
.subscribe(item => this.item = item);
}
goToItemThree() {
console.log("goToNextItem");
this.routerExtensions.navigate(['/item', 3]);
}
backToPrevious() {
this.routerExtensions.backToPreviousPage();
}
back() {
this.routerExtensions.back();
}
}