How to Create an Angular Project from Scratch ?
Last Updated :
28 Mar, 2024
To create an Angular project from scratch, we'll need Node.js and npm installed on our computer. Once installed, we can use Angular CLI, a command-line tool, to quickly set up a new Angular project with a basic structure. After creating the project, we can start coding our application using TypeScript, HTML, and CSS files located in the project directory. Angular CLI simplifies tasks like serving the application locally for development, generating components, and managing dependencies, making it easy to get started with Angular development even for beginners.
Steps to create Angular Project from Scratch:
Step 1: Install Angular CLI:
Angular CLI (Command Line Interface) is a powerful tool for creating and managing Angular projects. You can install it globally using npm by running the following command in your terminal or command prompt:
npm install -g @angular/cli
Step 2: Create a New Angular Project:
Once Angular CLI is installed, you can use it to create a new Angular project. Navigate to the directory where you want to create your project and run the following command:
ng new my-angular-app
Step 3: Serve Your Angular Application:
After the project is created, navigate into the project directory then use an Angular CLI to serve your application locally by running:
ng serve
Step 4: Create a Component:
Use Angular CLI to generate a new component. Open your terminal or command prompt, navigate to your project directory, and run the following command:
ng generate component my-component
Step 5: Configure Routes:
Define the routes for your application in the app-routing.module.ts file. You can use Angular's RouterModule to configure routes and associate components with specific URLs.
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from './home/home.component';
import { AboutComponent } from './about/about.component';
const routes: Routes = [
{ path: '', component: HomeComponent },
{ path: 'about', component: AboutComponent },
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
Step 6: Add Content to Components:
Open the HTML file of your component (component-name.component.ts, component-name.component.html, and component-name.component.css) and add the desired content.
Folder Structure:

The updated dependencies in package.json file will look like:
"dependencies": {
"@angular/animations": "^16.0.0",
"@angular/common": "^16.0.0",
"@angular/compiler": "^16.0.0",
"@angular/core": "^16.0.0",
"@angular/forms": "^16.0.0",
"@angular/platform-browser": "^16.0.0",
"@angular/platform-browser-dynamic": "^16.0.0",
"@angular/router": "^16.0.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.13.0"
}
Example: In this example we'll create a simple GFG AboutUs page using Angular
HTML
<!-- app.component.html -->
<div>
<h1 style="text-align: center; color: green">GeeksforGeeks</h1>
<div style="margin-left: 20px">
<h2>About Us</h2>
<p>
<strong>1. Company Profile and Brand:</strong><br />
GeeksforGeeks is a leading platform that provides
computer science resources and coding challenges for
programmers and technology enthusiasts, along with
interview and exam preparations for upcoming aspirants.
With a strong emphasis on enhancing coding skills and
knowledge, it has become a trusted destination for over
12 million plus registered users worldwide. The platform
offers a vast collection of tutorials, practice problems,
interview tutorials, articles, and courses,
covering various domains of computer science.
<br /><br />
Our exceptional mentors hailing from top colleges &
organizations have the ability to guide you on a
journey from the humble beginnings of coding to
the pinnacle of expertise. Under their guidance watch
your skills flourish as we lay the foundation and
help you conquer the world of coding.
</p>
<p>
<strong>2. Company Founders/Directors:</strong><br />
Our founder Sandeep Jain is a visionary entrepreneur
and esteemed computer science expert. Fueled by his
unwavering passion for coding and education, laid the
very bedrock upon which GeeksforGeeks stands today, and his
indomitable spirit has been instrumental in its remarkable
growth and resounding success. As the steadfast driving
force behind the company, Sandeep remains a beacon of
guidance and inspiration, propelling the team
to constantly challenging limits and craft transformative
learning experiences.
</p>
</div>
</div>
JavaScript
//app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
}
JavaScript
//app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
To start the application run the following command.
ng serve
Output:

Similar Reads
How to create class in Angular Project?
In Angular, TypeScript is the primary language for writing code. One of the fundamental concepts in TypeScript is classes, which allow you to define blueprints for creating objects with properties and methods. In this article, we'll explore how to create classes in Angular projects and understand th
2 min read
How to Create a new module in Angular ?
Modules are most important when it comes to building strong and scalable Angular applications. They help organize your code, promote modularity, and improve maintainability. It encourages collaboration among developers by grouping related components, directives, pipes, and services. In this article,
3 min read
How to bundle an Angular app for production?
Introduction Before deploying the web app, Angular provides a way to check the behavior of the web application with the help of a few CLI commands. Usually, the ng serves command is used to build, watch, and serve the application from local memory. But for deployment, the behavior of the application
4 min read
Create Project with App Module in Angular 17
When you try to create the Angular 17 application, you notice that the app.module.ts file is missing. Angular 17 introduces a significant change with Standalone configuration as the default in projects. But if you still want to work with the old folder structure then follow this article to the end.
6 min read
How to create the dynamic forms in AngularJS ?
In AngularJS, we need to create dynamic forms to make the user interact. We can create and apply different behaviors to the forms to represent and accept the data from the user. We can create dynamic forms using ng-repeat and ng-show in AngularJS. In this article, we will see how we can create dynam
7 min read
How to bind select element to an object in Angular ?
AngularJS is a JavaScript-based framework. It can be used by adding it to an HTML page using a tag. AngularJS helps in extending the HTML attributes with the help of directives and binding of data to the HTML with expressions. An Angular service is a broad category that consists of any value, functi
4 min read
How to execute a routing in the AngularJS framework ?
In this article, we will learn about how we can perform routing in AngularJS, along with understanding its implementation through the code example. Â Routing in AngularJS helps to develop Single Page Applications, which is a web app that loads only a single page, and the part of the page instead of
7 min read
How to Create Todo List in Angular 7 ?
The ToDo app is used to help us to remember some important task. We just add the task and when accomplished, delete them. This to-do list uses various Bootstrap classes that make our web application not only attractive but also responsive. Approach: Create a new angular app using following command:
2 min read
How to create module with Routing in Angular 9 ?
Angular applications are modular, and NgModules is Angular's own modular architecture. NgModules are containers for closely integrated application domains, workflows, or feature sets that comprise cohesive code blocks. Their scope is governed by the NgModule they include, and they can contain compon
4 min read
Folder Structure of Angular Project
Creation and Organization of an Angular Project in a well-planned manner is very important for readability, scalability, and manageability. A clear structure helps in managing code, configurations, modules and services effectively. In this article, we are going to have a clear understanding of the f
4 min read