Run ng generate component component-name
to generate a new component. You can also use ng generate directive|pipe|service|class|module
.
ng g c customer
ng g d search-box
ng g s general-data
Angular will give out a warning line after this command:
WARNING Service is generated but not provided, it must be provided to be used
After generating a service, we must go to its owning module and add the service to the providers
array.
ng g s general-data2 -m app.module
# class
ng g cl models/customer
# interface
ng g i models/person
# enum
ng g enum models/gender
ng g pipe shared/init-caps
Create a login directory and generate a login module in that directory.
ng g module login/login.module
Generate a module called admin and add routing feature to it.
ng g module admin --routing
Set up via Karma, Jasmine:
- Run
ng test
to execute the unit tests via Karma.
Set up with Protractor:
- Run
ng e2e
to execute the end-to-end tests via Protractor. - Before running the tests make sure you are serving the app via
ng serve
.
ng set default.styleExt css
ng new my-app --routing --style scss
- To get more help on the Angular CLI use
ng help
or go check out the Angular CLI README. ng doc component
to look up documentation for features.ng serve --help
to look up doc forng serve
command.