-
-
Notifications
You must be signed in to change notification settings - Fork 241
/
Copy pathsecond.component.ts
60 lines (51 loc) · 1.86 KB
/
second.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
import { Component, OnInit, OnDestroy, ViewContainerRef } from "@angular/core";
import { ActivatedRoute, Router, Route } from "@angular/router";
import { ModalDialogService, ModalDialogOptions } from "nativescript-angular";
import { Page } from "tns-core-modules/ui/page";
import { Observable } from "rxjs";
import { map } from "rxjs/operators";
import { RouterExtensions } from "nativescript-angular/router";
import { ModalComponent } from "./modal/modal.component";
@Component({
selector: "second",
template: `
<ActionBar title="Second Title">
<ActionItem text="ACTION2"></ActionItem>
</ActionBar>
<ActionBarExtension *ngIf="(id$ | async) === 2">
<ActionItem text="ADD" ios.position="right"></ActionItem>
</ActionBarExtension>
<StackLayout>
<Label [text]="'Second Component: ' + (id$ | async)" class="title"></Label>
<Button text="Show Modal" (tap)="onShowModal()"></Button>
<Button text="Back" (tap)="back()"></Button>
</StackLayout>`
})
export class SecondComponent implements OnInit, OnDestroy {
public id$: Observable<number>;
constructor(route: ActivatedRoute,
private routerExtensions: RouterExtensions,
private viewContainerRef: ViewContainerRef,
private modalService: ModalDialogService) {
this.id$ = route.params.pipe(map(r => +r["id"]));
}
ngOnInit() {
console.log("SecondComponent - ngOnInit()");
}
ngOnDestroy() {
console.log("SecondComponent - ngOnDestroy()");
}
back() {
this.routerExtensions.back();
}
onShowModal() {
let options: ModalDialogOptions = {
viewContainerRef: this.viewContainerRef,
context: {
},
fullscreen: true
};
this.modalService.showModal(ModalComponent, options).then((dialogResult: string) => {
});
}
}