Generates the initial setup for state management and registering new feature states. It registers the @ngrx/store-devtools
integration and generates a state management file containing the state interface, the object map of action reducers and any associated meta-reducers.
ng generate store State [options]
ng generate st State [options]
Provide the path to a file containing an Angular Module
and the feature state will be added to its imports
array using StoreModule.forFeature
or StoreModule.forRoot
.
--module
- Alias:
-m
- Type:
string
- Alias:
When used with the --module
option, it registers the state within the Angular Module
using StoreModule.forRoot
. The --root
option should only be used to setup the global @ngrx/store
providers.
--root
- Type:
boolean
- Default:
false
- Type:
Provide the folder where the state files will be created.
--statePath
- Type:
string
- Default:
reducers
- Type:
Generate the initial state management files and register it within the app.module.ts
ng generate store State --root --module app.module.ts
Generate an Admin
feature state within the admin
folder and register it with the admin.module.ts
in the same folder.
ng generate module admin --flat false
ng generate store Admin -m admin/admin.module.ts
Generate the initial state management files within a store
folder and register it within the app.module.ts
ng generate store State --root --statePath store --module app.module.ts