Creating an Angular Application
After installing Node.js and Angular CLI, we can create our first Angular application using the Angular CLI.
What is an Angular Application?
An Angular application is a web application built using the Angular framework. Angular provides components, templates, services, routing, forms and other features required to develop modern web applications.
Angular CLI provides the ng new command to create a new Angular application with the required project structure.
In Simple Words
The ng new command creates a ready-to-use Angular project with the required files, folders and configuration.
Angular Application Creation Flow
Open Terminal
Open Command Prompt or Terminal.
Run ng new
Create a new Angular project.
Configure
Select project configuration options.
Project Ready
Angular creates the project files.
Step 1: Open Terminal
Open Command Prompt, PowerShell or Terminal on your computer.
Step 2: Create a New Angular Application
Use the following command to create a new Angular application:
ng new CIITStudentApp
Expected Result
Angular CLI starts the project creation process and asks for the required project configuration options.
Understanding the Project Name
In the command:
ng new CIITStudentApp
Step 3: Angular Project Configuration
During project creation, Angular CLI may ask configuration questions depending on the Angular version and project setup.
Stylesheet Configuration
Select the stylesheet format required by the project.
Routing
Configure routing when the application requires multiple pages or routes.
Additional Configuration
Select additional options according to the project requirements.
Step 4: Angular Creates the Project
After the configuration is completed, Angular CLI creates the application folder and generates the required project files.
CREATE CIITStudentApp/
CREATE CIITStudentApp/src/
CREATE CIITStudentApp/src/app/
CREATE CIITStudentApp/angular.json
CREATE CIITStudentApp/package.json
Expected Result
A new Angular project named CIITStudentApp is created successfully.
Step 5: Move Into the Project Folder
After creating the application, move into the project folder using the cd command.
cd CIITStudentApp
Why use cd?
The cd command changes the current directory to the Angular project folder.
Step 6: Run the Angular Application
Start the Angular development server using:
ng serve
Expected Output
Angular starts the development server and provides a local URL for opening the application.
Angular Application Running Flow
Basic Angular Project Structure
After creating the application, Angular CLI generates a structured project containing configuration files, source files and application files.
CIITStudentApp
│
├── src
│ ├── app
│ ├── assets
│ ├── index.html
│ └── main.ts
│
├── angular.json
├── package.json
├── tsconfig.json
└── README.md
Complete Angular Application Creation
Common Issues
'ng' is not recognized
Make sure Angular CLI is installed correctly and restart the terminal before trying again.
Project Name Error
Use a valid project name without spaces or unsupported characters.
Port Already in Use
If the default development port is already being used, Angular CLI can use another available port.
Summary
Angular CLI provides the ng new command for creating a new Angular application.
The basic process is ng new → Configure Project → Create Files → cd Project → ng serve .
After starting the development server, the application can be opened using http://localhost:4200.
In the next topic, we will learn about Angular Project Structure.