Ng command can be used for different purposes in angular cli project.
They are as follows:-
ng g service my-new-service
ng g class my-new-class
ng g interface my-new-interface
ng g enum my-new-enum
ng g module my-module
The CLI supports routing in several ways:
@angular/routerNPM package when creating or initializing a project.
ng g module my-module --routingto create a separate file
my-module-routing.module.tsto store the module routes.
The file includes an empty
Routes object that you can fill with routes to different components and/or modules.
--routing option also generates a default component with the same name as the module.
ng newto create a
app-routing.module.tsfile when you create or initialize a project.
ng build can specify both a build target (
-- target=development) and an environment file to be used with that build (
-- environment=dev or
--environment=prod). By default, the development build target and environment are used.
This Tests will execute after a build is executed via Karma and it will automatically watch your files for changes. You can run tests a single time via
Before running the tests make sure you are serving the app via
End-to-end tests are run via Protractor.
You can deploy your apps quickly via:
You can lint your app code by running
ng lint. This will use the
lint npm script that in generated projects uses
You can modify these scripts in
package.json to run whatever tool you prefer.
To turn on auto completion use the following commands:
Windows users using gitbash:
ng new sassy-project –style=sass
ng set defaults.styleExt scss
ng update will check for changes in all the auto-generated files created by
ng new and allow you to update yours.