-
-
Notifications
You must be signed in to change notification settings - Fork 241
/
Copy pathfirst.component.ts
62 lines (51 loc) · 2.2 KB
/
first.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { Component, OnInit, OnDestroy, OnChanges, DoCheck } from "@angular/core";
import { ActivatedRoute, Router, Route } from "@angular/router";
import { Location } from "@angular/common";
import { RouterExtensions } from "nativescript-angular/router";
import { Page } from "tns-core-modules/ui/page";
import { CounterService } from "~/counter.service";
import { Observable } from "rxjs";
@Component({
selector: "first",
template: `
<StackLayout>
<Label text="FirstComponent" class="header"></Label>
<Button text="GO TO SECOND" automationText="GO TO SECOND" [nsRouterLink]="['/second','1']"></Button>
<Button text="GO TO C-LESS SECOND" automationText="GO TO C-LESS SECOND" [nsRouterLink]="['/c-less', 'deep', '100', 'detail', '200']"></Button>
<Button text="GO TO LAZY HOME" automationText="GO TO LAZY HOME" [nsRouterLink]="['/lazy','home']"></Button>
<Button text="GO TO C-LESS LAZY" automationText="GO TO C-LESS LAZY" [nsRouterLink]="['/lazy','nest','more']"></Button>
<Button text="BACK" automationText="BACK" (tap)="goBack()"></Button>
<Button text="RESET" automationText="RESET" (tap)="reset()"></Button>
<Label [text]="message"></Label>
<Label [text]="'CHECK: ' + doCheckCount"></Label>
<Label [text]="'COUNTER: ' + (service.counter$ | async)"></Label>
</StackLayout>`
})
export class FirstComponent implements OnInit, OnDestroy, DoCheck {
public message: string = "";
public doCheckCount: number = 0;
constructor(private routerExt: RouterExtensions, page: Page, private service: CounterService) {
console.log("FirstComponent - constructor() page: " + page);
}
ngOnInit() {
console.log("FirstComponent - ngOnInit()");
}
ngOnDestroy() {
console.log("FirstComponent - ngOnDestroy()");
}
ngDoCheck() {
this.doCheckCount++;
console.log("FirstComponent - ngDoCheck(): " + this.doCheckCount);
}
reset() {
this.doCheckCount = 0;
}
goBack() {
this.message = "";
if (this.routerExt.canGoBack()) {
this.routerExt.back();
} else {
this.message = "canGoBack() - false"
}
}
}