Skip to content

Commit

Permalink
Updated standalone example.
Browse files Browse the repository at this point in the history
  • Loading branch information
lindolo25 committed Oct 26, 2024
1 parent 420b786 commit fc27f1c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
16 changes: 14 additions & 2 deletions test-angular-versions/v18-standalone/src/app/lazy/lazy.module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { NgModule } from '@angular/core';
import { InjectionToken, NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { UIRouterModule } from '@uirouter/angular';
import { LazyComponent } from './lazy.component';

export const states = [
{ name: 'lazy', url: '/lazy', component: LazyComponent },
{ name: 'lazy.child', url: '/child', component: LazyComponent },
{
name: 'lazy.child',
url: '/child',
loadComponent: () => import("./lazy2.component").then(m => m.Lazy2Component)
},
{
name: 'lazy.child.viewtarget',
url: '/viewtarget',
Expand All @@ -16,8 +20,16 @@ export const states = [
},
];

export const LAZY_PROVIDER_TOKE = new InjectionToken<string>("lazyProvider");

@NgModule({
imports: [CommonModule, UIRouterModule.forChild({ states: states })],
providers: [
{
provide: LAZY_PROVIDER_TOKE,
useValue: "provided value"
}
],
declarations: [LazyComponent],
})
export class LazyModule {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Component, inject, input } from '@angular/core';
import { Ng2StateDeclaration, UIRouterModule } from '@uirouter/angular';
import { LAZY_PROVIDER_TOKE } from './lazy.module';

@Component({
selector: 'app-lazy',
standalone: true,
imports: [UIRouterModule],
template: `
<p>{{ state().name }} works!</p>
<p>{{ _providedString }}</p>
<ui-view></ui-view>
`,
})
export class Lazy2Component {
state = input.required<Ng2StateDeclaration>({ alias: '$state$' });
_providedString = inject<string>(LAZY_PROVIDER_TOKE);
}

0 comments on commit fc27f1c

Please sign in to comment.