angularcommand-line-interfaceangular-cliangular-module

ng g module my-module only generates the module.ts file


ng g module my-module only generates the module.ts file. But I need all the files css, HTML, ts, spec, module.ts. How can I generate all of them at a time using cli?


Solution

  • You can do by angular cli cmd ,but it will take two steps/cmds separately or one cmd line union by and &:

    first create module with/out routing as you preferred:

    ng g m /pages/home-page --routing=true 
    

    then in a second cmd just create component:

    ng g c /pages/home-page
    

    or you can combine cmds in one cmd with && operator:

     ng g m /pages/home-page --routing=true && ng g c /pages/home-page
    

    Angular cli will automatic include your component to the module that you create in first cmd, if you don't want to angular auto import ,just add --skip-import options:

     ng g c /pages/home-page --skip-import