-
-
Notifications
You must be signed in to change notification settings - Fork 241
/
Copy pathlazy-loaded.module.ts
43 lines (38 loc) · 1.26 KB
/
lazy-loaded.module.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
import { Component, NgModule } from "@angular/core";
import { NativeScriptModule } from "nativescript-angular/nativescript.module";
import { NativeScriptRouterModule } from "nativescript-angular/router";
import { ModalDialogParams } from "nativescript-angular/directives/dialogs";
import { Page } from "ui/page";
import { lazyLoadHooksLogProvider } from "./main";
import { SecondComponent } from "./second.component";
const routes = [
{ path: ":id", component: SecondComponent },
];
@Component({
selector: "modal-lazy-comp",
template: `<Label text="this is lazily loaded modal component"></Label>`
})
export class ModalLazyComponent {
constructor(public params: ModalDialogParams, private page: Page) {
page.on("shownModally", () => {
const result = this.params.context;
this.params.closeCallback(result);
});
}
}
@NgModule({
declarations: [
SecondComponent,
ModalLazyComponent
],
entryComponents: [ModalLazyComponent], // when lazily loaded and opened via modal on demand
imports: [
NativeScriptModule,
NativeScriptRouterModule,
NativeScriptRouterModule.forChild(routes)
],
providers: [
lazyLoadHooksLogProvider
]
})
export class SecondModule { }