-
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathsplit-view-demo.component.ts
More file actions
52 lines (49 loc) · 1.57 KB
/
split-view-demo.component.ts
File metadata and controls
52 lines (49 loc) · 1.57 KB
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
import { Component, inject, NO_ERRORS_SCHEMA, OnInit, AfterViewInit } from '@angular/core';
import {
NativeScriptCommonModule,
NativeScriptRouterModule,
PageRouterOutlet,
RouterExtensions,
} from '@nativescript/angular';
import { SplitViewState } from './split-view.state';
@Component({
selector: 'ns-split-view-demo',
templateUrl: './split-view-demo.component.html',
imports: [NativeScriptCommonModule, NativeScriptRouterModule, PageRouterOutlet],
schemas: [NO_ERRORS_SCHEMA],
})
export class SplitViewDemoComponent implements OnInit, AfterViewInit {
router = inject(RouterExtensions);
splitViewState = inject(SplitViewState);
ngOnInit() {
console.log('[SplitViewDemo] ngOnInit');
}
ngAfterViewInit() {
console.log('[SplitViewDemo] ngAfterViewInit - view is initialized, navigating to outlets');
// Use setTimeout to ensure the view is fully rendered and outlets are registered
setTimeout(() => {
console.log('[SplitViewDemo] Navigating to outlets...');
this.router
.navigate(
[
'/',
{
outlets: {
primary: ['primary'],
secondary: ['secondary'],
supplementary: ['supplementary'],
inspector: ['inspector'],
},
},
],
{ animated: false },
)
.then((success) => {
console.log(`[SplitViewDemo] navigation result: ${success}`);
})
.catch((err) => {
console.error(`[SplitViewDemo] navigation error: ${err}`);
});
}, 0);
}
}