forked from hypery2k/nativescript-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrouter-outlet.ts
64 lines (59 loc) · 1.9 KB
/
router-outlet.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
63
64
import { ApplicationRef } from "@angular/core";
// >> router-outlet-example
import { Component, NgModule } from "@angular/core";
import { platformNativeScriptDynamic } from "nativescript-angular/platform";
import { NativeScriptRouterModule } from "nativescript-angular/router";
import { Router, NavigationStart, NavigationEnd } from "@angular/router";
import { routes } from "./app.routes";
import { FirstComponent, SecondComponent } from "./navigation-common";
@Component({
selector: "navigation-test",
template: `
<StackLayout>
<StackLayout class="nav">
<Button text="First"
[nsRouterLink]="['/first']"></Button>
<Button text="Second"
[nsRouterLink]="['/second']"></Button>
</StackLayout>
<router-outlet></router-outlet>
</StackLayout>
`
})
export class NavigationApp {
// >> (hide)
public startEvent: any;
public endEvent: any;
public done: Promise<void>;
constructor(public router: Router, public appRef: ApplicationRef) {
this.done = new Promise<void>((resolve, reject) => {
this.router.events.subscribe((e) => {
if (e instanceof NavigationStart) {
this.startEvent = e;
}
if (e instanceof NavigationEnd) {
this.endEvent = e;
resolve();
}
});
});
}
// << (hide)
}
@NgModule({
bootstrap: [NavigationApp],
entryComponents: [FirstComponent, SecondComponent],
imports: [
NativeScriptRouterModule,
NativeScriptRouterModule.forRoot(routes)
]
})
export class NavigationAppModule { }
// >> (hide)
function start_snippet() {
// << (hide)
platformNativeScriptDynamic().bootstrapModule(NavigationAppModule);
// >> (hide)
}
// << (hide)
// << router-outlet-example