-
-
Notifications
You must be signed in to change notification settings - Fork 241
/
Copy pathmodal-shared-second.component.ts
44 lines (39 loc) · 1.37 KB
/
modal-shared-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
import { Component } from "@angular/core";
import { ModalDialogOptions, ModalDialogService } from "@nativescript/angular";
import { ViewContainerRefService } from "../shared/ViewContainerRefService";
import { ModalViewComponent } from "../modal-shared/modal-view.component";
import { RouterExtensions } from "@nativescript/angular";
@Component({
selector: "ns-second",
moduleId: module.id,
template: `
<StackLayout class="page">
<Button text="Show Shared Modal" (tap)="onRootModalTap()"></Button>
<Button text="go back" (tap)="onBackTap()"></Button>
<Label text="second component"></Label>
</StackLayout>
`
})
export class ModalSharedSecondComponent {
constructor(
private _modalService: ModalDialogService,
private _viewContainerRefService: ViewContainerRefService,
private _routerExtensions: RouterExtensions
) { }
onRootModalTap(): void {
const options: ModalDialogOptions = {
context: {},
fullscreen: true,
viewContainerRef: this._viewContainerRefService.root,
};
this._modalService.showModal(ModalViewComponent, options)
.then((result: string) => {
console.log(result);
});
}
onBackTap() {
if (this._routerExtensions.canGoBack()) {
this._routerExtensions.back();
}
}
}