CLI
Execute the command:
ng generate module {module-name}
Shorter command:
ng g m {module-name}
For example, you can create an AuthenticationModule like this:
ng generate module authentication
To automatically create a routing module with your new module, you can add --routing=true
:
ng g m {module-name} --routing=true
Execute the command:
ng generate component {module-directory-name}/{component-name}
Shorter command:
ng g c {module-directory-name}/{component-name}
For example, you can create a LoginComponent like this:
ng g c authentication/login
Execute the command:
ng generate service {module-directory-name}/services/{service-name}
Shorter command:
ng g s {module-directory-name}/services/{service-name}
For example, you can create an AuthenticationService like this:
ng g s authentication/services/authentication