The Angular CLI is a tool to initialize, scaffold and maintain the angular apps.
Before you Installing, will need to check Angular CLI and your project have dependencies that require Node 6.9.0 or higher, together with NPM 3 or higher.
npm install -g @angular/cli
The Angular CLI will add reference automatically for components, directives and pipes in your apps “app.module.ts”.
How to Generating and serving an Angular project using development server?
Follow the below commons to generating and serving an angular project -
ng new YOUR-PROJECT-NAME
And after execute the command - ng serve, your project will automatically reload to “http://localhost:4200/”.
We can also configure the default HTTP host and port by the below commands-
ng serve --host 0.0.0.0 --port 3201
How To Generating Components, Directives, Pipes and Services in Apps?
Below commands are used to generating -
· Component – [ng g component my-new-component]
· Directive – [ng g directive my-new-directive]
· Pipe – [ng g pipe my-new-pipe]
· Service - [ng g service my-new-service]
· Class - [ng g class my-new-class]
· Guard - [ng g guard my-new-guard]
· Interface -[ng g interface my-new-interface]
· Enum - [ng g enum my-new-enum]
· Module - [ng g module my-module]
How To Updating Angular CLI?
If you are using Angular CLI lesser version, un-install Angular CLI packages and install new versions.
Global Package -
npm uninstall -g @angular/cli
npm cache clean
npm install -g @angular/cli@latest
Local project package -
rm -rf node_modules dist # use rmdir /S/Q node_modules dist in Windows Command Prompt; use rm -r -fo node_modules,dist in Windows PowerShell
npm install --save-dev @angular/cli@latest
Running Unit Tests in Your Projects -
Tests will execute after a build is executed via Karma and it will automatically watch your files changes. You can run Tests a single time via --watch=false.
Some Additional Commands for Angular -
· ng new
· ng serve
· ng generate
· ng lint
· ng test
· ng e2e
· ng build
· ng get/ng set
· ng doc
· ng eject
· ng xi18n