To create a directive:
ng generate guard guardName
Or
ng g g guardName
If your angular application contains multiple modules you will get an error because Angular CLI does not know with which module the newly generated guard should be registered.
To avoid this you can use
ng g g guardName --skip-import
Angular CLI don't import and register the generated guard with any module.
Or you can use below command to tell the angular cli with which module it should register when multiple modules are present in your application.
ng g g guardName -m=app.module
In the above, it will register to the app module in your angular application
You can use --flat option to create a dedicated folder for the guard.
You can use --spec to specifies if a spec file should be generated or not by passing true or false value.
ng generate guard guardName
Or
ng g g guardName
If your angular application contains multiple modules you will get an error because Angular CLI does not know with which module the newly generated guard should be registered.
To avoid this you can use
ng g g guardName --skip-import
Angular CLI don't import and register the generated guard with any module.
Or you can use below command to tell the angular cli with which module it should register when multiple modules are present in your application.
ng g g guardName -m=app.module
In the above, it will register to the app module in your angular application
You can use --flat option to create a dedicated folder for the guard.
You can use --spec to specifies if a spec file should be generated or not by passing true or false value.
No comments:
Post a Comment