-
-
Notifications
You must be signed in to change notification settings - Fork 241
/
Copy pathlayout.component.ts
49 lines (43 loc) · 1.58 KB
/
layout.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
import { Component, ViewContainerRef } from "@angular/core";
import { Router, NavigationEnd } from "@angular/router";
import { NSLocationStrategy } from "@nativescript/angular";
import { ModalDialogService, ModalDialogOptions } from "@nativescript/angular/directives/dialogs";
import { ModalViewComponent } from "./modal-shared/modal-view.component";
import { ViewContainerRefService } from "./shared/ViewContainerRefService";
import { AppModule } from "./app.module";
@Component({
selector: "ns-layout",
templateUrl: "layout.component.html",
})
export class LayoutComponent {
constructor(
private modal: ModalDialogService,
private router: Router,
private location: NSLocationStrategy,
private vcRef: ViewContainerRef,
private viewContainerRefService: ViewContainerRefService) {
this.router.events.subscribe(e => {
if (e instanceof NavigationEnd) {
console.log("[ROUTER]: " + e.toString());
console.log(this.location.toString());
}
});
this.viewContainerRefService.root = this.vcRef;
}
ngOnInit() {
if (AppModule.root === "layout-modal") {
console.log("Show modal page from tab root view!");
this.onRootModalTap();
}
}
onRootModalTap(): void {
const options: ModalDialogOptions = {
viewContainerRef: this.viewContainerRefService.root,
context: {},
fullscreen: true
};
this.modal.showModal(ModalViewComponent, options).then((result: string) => {
console.log(result);
});
}
}