Skip to content

Commit 7e5aae1

Browse files
vakrilovSvetoslavTsenov
vakrilov
authored andcommitted
test: Add nav buttons to details pages
1 parent 2a5da3b commit 7e5aae1

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

e2e/router-tab-view/app/player/player-detail.component.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22
<StackLayout flexDirection="column" class="page" class="m-15">
33
<Label class="h2" [text]="item.id"></Label>
44
<Label class="h2" [text]="item.name"></Label>
5+
6+
<Button text="next" [nsRouterLink]="['../', item.id + 1]"></Button>
7+
<Button text="players" [nsRouterLink]="['../../players']"></Button>
58
</StackLayout>

e2e/router-tab-view/app/player/player-detail.component.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Component, OnInit } from "@angular/core";
22
import { ActivatedRoute } from "@angular/router";
33

44
import { DataService, DataItem } from "../data.service";
5+
import { Subscription } from "rxjs/Subscription";
56

67
@Component({
78
selector: "ns-player-details",
@@ -10,14 +11,21 @@ import { DataService, DataItem } from "../data.service";
1011
})
1112
export class PlayerDetailComponent implements OnInit {
1213
item: DataItem;
14+
subscription: Subscription;
1315

1416
constructor(
1517
private data: DataService,
1618
private route: ActivatedRoute
1719
) { }
1820

1921
ngOnInit(): void {
20-
const id = +this.route.snapshot.params["id"];
21-
this.item = this.data.getPlayer(id);
22+
this.subscription = this.route.params.subscribe(params => {
23+
const id = +params["id"];
24+
this.item = this.data.getPlayer(id);
25+
})
26+
}
27+
28+
ngOnDestroy() {
29+
this.subscription.unsubscribe();
2230
}
2331
}

e2e/router-tab-view/app/team/team-detail.component.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22
<StackLayout flexDirection="column" class="page" class="m-15">
33
<Label class="h2" [text]="item.id"></Label>
44
<Label class="h2" [text]="item.name"></Label>
5+
6+
<Button text="next" [nsRouterLink]="['../', item.id + 1]"></Button>
7+
<Button text="teams" [nsRouterLink]="['../../teams']"></Button>
58
</StackLayout>

e2e/router-tab-view/app/team/team-detail.component.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Component, OnInit } from "@angular/core";
22
import { ActivatedRoute } from "@angular/router";
33

44
import { DataService, DataItem } from "../data.service";
5+
import { Subscription } from "rxjs/Subscription";
56

67
@Component({
78
selector: "ns-team-details",
@@ -10,14 +11,21 @@ import { DataService, DataItem } from "../data.service";
1011
})
1112
export class TeamDetailComponent implements OnInit {
1213
item: DataItem;
14+
subscription: Subscription;
1315

1416
constructor(
1517
private data: DataService,
1618
private route: ActivatedRoute
1719
) { }
1820

1921
ngOnInit(): void {
20-
const id = +this.route.snapshot.params["id"];
21-
this.item = this.data.getTeam(id);
22+
this.subscription = this.route.params.subscribe(params => {
23+
const id = +params["id"];
24+
this.item = this.data.getTeam(id);
25+
})
26+
}
27+
28+
ngOnDestroy() {
29+
this.subscription.unsubscribe();
2230
}
2331
}

0 commit comments

Comments
 (0)