Installing Angular
Download and Install Node Package Manager. NPM is a must have to work with Angular.
Note: ng commands such as install generate serve build etc only require the first letter of the command. Example ng g c <your component name>. g for generate and c for component.
Brand new installation of Angular starts here (This takes a few minutes. 200mb of files)
npm install –g @angular/cli
Updating an older Angular 5.x or newer application. Go to the root directory of where your projects are stored and run the following command.
npm install --save-dev @angular/cli@latest
After Angular is installed. For a new application use the ng new application_name command.
ng new app_name --routing --style scss
The Angular CLI makes it easy to create an application that already works, right out of the box. It already follows our best practices!
ng generate
Generate components, routes, services and pipes with a simple command. The CLI will also create simple test shells for all of these.
Type localhost:4200 to view your application
ng serve OR Open to a new window ng serve –o
OR if you cannot use 4200 pick another port
ng serve –o –port=4202
AND if you want faster compile times. You have a couple of choices
Ahead of Time (AOT) – Compiles your app at build time: ng serve –aot
Just In Time (JIT) – Compiles your app in your browser: ng serve –jit
When you ready to deploy.
To compile your application for production:
Complete Build (Use this for Production ready build) à ng build –prod