Generates a reducer file that contains a state interface, and initial state object for the reducer, and a reducer function.
ng generate reducer ReducerName [options]
ng generate r ReducerName [options]
Nest the reducer file within a folder based on the reducer name
.
--flat
- Type:
boolean
- Default:
true
- Type:
Group the reducer file within an reducers
folder.
--group
- Alias:
-g
- Type:
boolean
- Default:
false
- Alias:
Provide the path to a file containing an Angular Module
and the entity reducer will be added to its imports
array using StoreModule.forFeature
.
--module
- Alias:
-m
- Type:
string
- Alias:
Provide the path to a reducers
file containing a state interface and a object map of action reducers. The generated reducer interface will be imported added to the first defined interface within the file. The reducer will be imported and added to the first defined object with an ActionReducerMap
type.
--reducers
- Alias:
-r
- Type:
string
- Alias:
Generate a spec file alongside the reducer file.
--spec
- Type:
boolean
- Default:
true
- Type:
Generate a User
reducer file add it to a defined map of reducers generated from a feature state.
ng generate reducer User --reducers reducers/index.ts
Generate User
a reducer file within a nested folder based on the reducer name.
ng generate reducer User --flat false
Generate a User
reducer and register it within the Angular Module
in app.module.ts
.
ng generate reducer User --module app.module.ts
Generate a User
reducer file within a nested reducers
folder
ng generate reducer User --group