Skip to content

Commit fc27f1c

Browse files
committed
Updated standalone example.
1 parent 420b786 commit fc27f1c

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

test-angular-versions/v18-standalone/src/app/lazy/lazy.module.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
import { NgModule } from '@angular/core';
1+
import { InjectionToken, NgModule } from '@angular/core';
22
import { CommonModule } from '@angular/common';
33
import { UIRouterModule } from '@uirouter/angular';
44
import { LazyComponent } from './lazy.component';
55

66
export const states = [
77
{ name: 'lazy', url: '/lazy', component: LazyComponent },
8-
{ name: 'lazy.child', url: '/child', component: LazyComponent },
8+
{
9+
name: 'lazy.child',
10+
url: '/child',
11+
loadComponent: () => import("./lazy2.component").then(m => m.Lazy2Component)
12+
},
913
{
1014
name: 'lazy.child.viewtarget',
1115
url: '/viewtarget',
@@ -16,8 +20,16 @@ export const states = [
1620
},
1721
];
1822

23+
export const LAZY_PROVIDER_TOKE = new InjectionToken<string>("lazyProvider");
24+
1925
@NgModule({
2026
imports: [CommonModule, UIRouterModule.forChild({ states: states })],
27+
providers: [
28+
{
29+
provide: LAZY_PROVIDER_TOKE,
30+
useValue: "provided value"
31+
}
32+
],
2133
declarations: [LazyComponent],
2234
})
2335
export class LazyModule {}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Component, inject, input } from '@angular/core';
2+
import { Ng2StateDeclaration, UIRouterModule } from '@uirouter/angular';
3+
import { LAZY_PROVIDER_TOKE } from './lazy.module';
4+
5+
@Component({
6+
selector: 'app-lazy',
7+
standalone: true,
8+
imports: [UIRouterModule],
9+
template: `
10+
<p>{{ state().name }} works!</p>
11+
<p>{{ _providedString }}</p>
12+
<ui-view></ui-view>
13+
`,
14+
})
15+
export class Lazy2Component {
16+
state = input.required<Ng2StateDeclaration>({ alias: '$state$' });
17+
_providedString = inject<string>(LAZY_PROVIDER_TOKE);
18+
}

0 commit comments

Comments
 (0)