angular-cli Working with angular-cli: Generating components, directives, pipes, services, etc.


The angular-cli tool can help you to scaffold different parts of an angular application (components, directives, pipes, services, classes, guards, interfaces, enums and modules).


  • ng generate [component | directive | service | pipe | class | enum | interface | guard | module] [name] [flags...]
  • ng g [c | d | s | p | cl | e | i | g | m] [name] [flags...]


component or cUsed to generate component
directive or dUsed to generate directives
service or sUsed to generate services
pipe or pUsed to generate pipes
class or clUsed to generate classes
enum or eUsed to generate enums
interfaces or iUsed to generate interfaces
guard or gUsed to generate guards
module or mUsed to generate modules
--flat or -fUsed to enable/disable directory creation
--inline-template or -itUsed to enable/disable inline html templates in components
--inline-style or -isUsed to enable/disable inline styles in components
--prefix or -pUsed to disable or change prefix
--spec or -sUsed to enable/disable .spec files creation
--skip-importUsed to skip the module import
--app or -aUsed to specify app name to use
--module or -mUsed to specify the declaring module
--view-encapsulation or -veUsed to specify the view encapsulation strategy in components
--change-detection or -cdUsed to specify the change detection strategy in components
--routing or -rUsed to specify if routing module file should be generated