Skip to content

Lazy Loading Store into a standalone component. #2104

Answered by arturovt
necronflux101 asked this question in Q&A
Discussion options

You must be logged in to vote

The provideStore and provideStates (standalone features available under the dev version) will also not allow providing states on components since they return environment providers. That would be possible to use on the ApplicationConfig when bootstrapping the app and Route providers.

In your case, you can have a separate module that imports the NGXS feature module, and then you import this module into the component:

@NgModule({
  imports: [NgxsModule.forFeature([LazyState])]
})
export class LazyModule {}

@Component({
  selector: 'test',
  templateUrl: './test.component.html',
  styleUrls: ['./test.component.scss'],
  standalone: true,
  imports: [
    CommonModule,
    LazyModule // <----…

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@necronflux101
Comment options

@arturovt
Comment options

@arturovt
Comment options

Answer selected by necronflux101
Comment options

You must be logged in to vote
2 replies
@hakimio
Comment options

@arturovt
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants