Full width home advertisement

Angular 7

Climb the mountains

Post Page Advertisement [Top]

Angular CLI makes it easy to start with any Angular project. Angular CLI comes with commands that help us create and start on our project very fast. Let us now go through the commands available to create a project, a component and services, change the port, etc.
To work with Angular CLI, we need to have it installed on our system. Let us use the following command for the same −
npm install -g @angular/cli
To create a new project, we can run the following command in the command line and the project will be created.
ng new PROJECT-NAME 
cd PROJECT-NAME 
ng serve //
ng serve // will compile and you can see the output of your project in the browser −
http://localhost:4200/
4200 is the default port used when a new project is created. You can change the port with the following command −
ng serve --host 0.0.0.0 --port 4201

Command for Angular Update

In case you want to update your application and its dependencies, you can use the following command −
ng update @angular/cli @angular/core
It will update core framework to the recent version, i.e., Angular 7 and also angular-cli. You can use above command with following options −

Angular Important Command List

The following table lists down a few important commands required while working with Angular 7 projects −
Sr.NoCommands and Description
1
Component
ng g component new-component
2
Directive
ng g directive new-directive
3
Pipe
ng g pipe new-pipe
4
Service
ng g service new-service
5
Module
ng g module my-module
6
Test
ng test
7
Build
ng build --configuration=production // for production environment
ng build --configuration=staging // for stating environment
Whenever a new module, a component, or a service is created, the reference of the same is updated in the parent module app.module.ts.

No comments:

Post a Comment

Bottom Ad [Post Page]