Some useful schematics.
npm install --save-dev ngx-schematics-collection
ng generate ngx-schematics-collection:form-control component-name
The command above will generate a component with NG_VALUE_ACCESSOR
related code.
The other parameters are same as generate component.
Using command below to generate a validator directive:
ng g ngx-schematics-collection:validator my-validator
or generate a async validator
ng g ngx-schematics-collection:validator my-validator --isAsync
The other parameters are same as generate directive.
You can create different types of route guard:
- CanActivate to mediate navigation to a route.
- CanActivateChild to mediate navigation to a child route.
- CanDeactivate to mediate navigation away from the current route.
- Resolve to perform route data retrieval before route activation.
- CanLoad to mediate navigation to a feature module loaded asynchronously.
Just choose a type of route guard, then use it to --type
parameter, for example: create a 'CanActivate' route guard:
ng g ngx-schematics-collection:route-guard route-guard-name --type=CanActivate
The other parameters are same as generate service.