Now we are going to learn the Angular CLI.
What is Angular CLI:
- The Angular CLI is a command-line interface tool that you use to initialize, develop, scaffold, and maintain Angular applications directly from a command shell.
- Angular CLI is the official tool for initializing and working with Angular projects.
- It saves you from the hassle of complex configurations and build tools like TypeScript Webpack, and so on.
Installing Angular CLI:
- Major versions of Angular CLI follow the supported major version of Angular, but minor versions can be released separately.
- Install the CLI using the npm package manager:
- To create, build, and serve a new, basic Angular project on a development server, go to the parent directory of your new workspace use the following commands:
ng new my-first-project
cd my-first-project
ng serve
Why is angular CLI used?
- The Angular CLI is used for much more than just creating an Angular project.
- It can be used to create components, services, pipes, directives and more.
- Also it helps in building, serving, testing etc. CLI itself is quite something to learn about, it makes Angular development workflow much easier and faster.
Ng new:
- The Angular CLI makes it easy to create an application that already works, right out of the box. It already follows our best practices.
- Creates a new workspace and an initial Angular application.
Syntax:
ng new <name> [options]
ng n <name> [options]
Ng Serve:
- ng serve command builds and serve the application. It rebuilds the application if changes occur. Here project is the name of the application as defined in angular.
- Easily test your app locally while developing.
Syntax:
ng serve <project> [options]
ng s <project> [options]
Floder Structure:
No comments:
Post a Comment