Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • AngularJS Tutorial
  • AngularJS Directives
  • AngularJS Functions
  • AngularJS Filters
  • AngularJS Examples
  • AngularJS Interview Questions
  • Angular ngx Bootstrap
  • AngularJS Cheat Sheet
  • AngularJS PrimeNG
  • JavaScript
  • Web Technology
Open In App
Next Article:
Getting Started with Angular
Next article icon

Getting Started with Angular

Last Updated : 15 Mar, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Angular is a front-end framework for building dynamic web applications. It allows the MVC (Model-View-Controller) architecture and utilizes TypeScript for building applications. So, Angular is an open-source JavaScript framework written in TypeScript. It is maintained by Google, and its primary purpose is to develop single-page applications. It enables users to create large applications in a maintainable manner.

Table of Content

  • What is Angular?
  • Features of Angular
  • Installing the Angular CLI
  • Understanding Angular Basic
  • Create a New Angular Project and workspace
  • Navigate to the Project preferences
  • Run the Angular Application
  • Example of a Basic Angular Application

Prerequisites

  • Familiar with CSS, HTML, and JavaScript.
  • NodeJs is installed on our machine.

What is Angular?

Angular is a popular open-source Typescript framework created by Google for developing web applications. Front-end developers use frameworks like Angular or React to present and manipulate data efficiently and dynamically. Angular has been actively updated and become more and more efficient with time, especially since the time the core functionality was moved to different modules.

Features of Angular

  • It uses components and directives. Components are the directives with a template.
  • It is written in Microsoft’s TypeScript language, which is a superset of ECMAScript 6 (ES6).
  • Angular is supported by all the popular mobile browsers.
  • Properties enclosed in “()” and “[]” are used to bind data between the view and the model.
  • It provides support for TypeScript and JavaScript.
  • Angular uses @Route Config{(…)} for routing configuration.
  • It has a better structure compared to AngularJS, easier to create and maintain for large applications but behind AngularJS in the case of small applications.
  • It comes with the Angular CLI tool.

Installing the Angular CLI

CLI is a command line interface. So, the Angular CLI can be installed either locally or globally. But it is often recommended to install it globally, thus installing Angular CLI globally using npm.

Open a terminal window and enter the following command line:

npm install -g @angular/cli

Screenshot-2024-03-16-204441

Understanding Angular Basic

1. Components

The component is the basic building block of Angular. It has a selector, template, style, and other properties, and it specifies the metadata required to process the component. 

Syntax to create components in Angular:

ng generate component my-component
export class Mycomponent{
title = 'Hello,Geeksforgeek!';

2. Modules

Modules are a way to group related components and directives, along with the services, pipes, and other codes that they rely on, into a single cohesive unit. Modules provide a way to keep the code organized and make it easier to reuse components and directives across different parts of the application. Modules are defined using the Angular NgModule decorator, which takes an object that specifies the components, directives, and other code that the module contains. 

Syntax to create modules in Angular

ng generate module my-module

3. Services

The Services is a function or an object that avails or limitsRouting to the application in AngularJS, ie., it is used to create variables/data that can be shared and can be used outside the component in which it is defined. Service facilitates built-in service or can make our own service.

Syntax to create services in Angular

ng generate service my-service

4. Templates and Data Binding

Templates and data binding play important role in creating dynamic and interactive user interfaces. Templates are HTML files enhanced with Angular-specific syntax, while data binding enables synchronization of data between the component's model and the view.

Syntax

<input [(ngModel)]="username">

5. Routing and Navigation

Routing enables navigation between different parts of the angular application. learn how to set up routing in your Angular project using Angular router.

// app-routing.module.ts
import { NgModule } from '@angular/core';
import { RouterModule, Routes } 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 { }

Create a New Angular Project and workspace

A project is a set of files that comprise an app, a library, or end-to-end tests.

Once Angular CLI is installed, you can create a new Angular project by running the following command:

ng new my-angular-app

The Angular CLI installs the necessary Angular npm packages and other dependencies.

It also creates the following workspace and start your project files:

  • A new workspace, with a root folder named my-angular-ap
  • An initial skeleton app project also called my-angular-app (in the src subfolder)

Screenshot-2024-03-16-205452

Navigate to the Project preferences

After the project is created, navigate to the project directory using the 'cd' command.

cd my-angular-app

Run the Angular Application

Once inside your project directory, you can run the Angular application using the following command:

ng serve

This command will compile the application and start a development server. By default,the application will be accessible at 'http://localhost:4200/' in your web browser.

Screenshot-2024-03-16-210035

Example of a Basic Angular Application

Creating a simple Angular component involves defining a TypeScript class with a @Component decorator. We are going to edit this component, thus opening the src folder-app-app.components.ts, and changing the title.

Screenshot-2024-03-16-214439

Modify the given files to see the results

HTML
<!-- app.component.html -->  <main class="main">     <div class="content">         <div class="left-side">              <h1>Hello, {{ title }}</h1>             <p>Congratulations! Your app is running. ?</p>         </div>         <div class="divider" role="separator" aria-label="Divider"></div>         <div class="right-side">         </div>     </div> </main>  <router-outlet /> 
CSS
/* app.component.css */  content_copyh1 {     color: #369;     font-family: Arial, Helvetica, sans-serif;     font-size: 250%; } 
JavaScript
// app.component.ts  import { Component } from '@angular/core'; import { RouterOutlet } from '@angular/router'; import App from '../client/src/App';  @Component({     selector: 'app-root',     standalone: true,     imports: [RouterOutlet],     templateUrl: './app.component.html',     styleUrl: './app.component.css' }) export class AppComponent {     title = 'GeeksForGeek first initiat project,welcome to Angular'; } 

Output
Screenshot-2024-03-16-214847


Next Article
Getting Started with Angular

S

surya9c5sb
Improve
Article Tags :
  • Web Technologies
  • AngularJS

Similar Reads

    Testing With The Angular HttpClientTestingModule
    Testing is an important part of software development, ensuring that your application functions correctly and meets the requirements. Angular provides a powerful module for testing HTTP requests called HttpClientTestingModule. This article will guide you through the process of setting up and using Ht
    2 min read
    Make HTTP requests in Angular?
    In Angular, making HTTP requests involves communicating with a server to fetch or send data over the internet. It's like asking for information from a website or sending information to it. Angular provides a built-in module called HttpClientModule, which simplifies the process of making HTTP request
    4 min read
    What is View in AngularJS ?
    In AngularJS, the View is what the user can see on the webpage. In an application (as per the user’s choice), the chosen view is displayed. For this purpose, the ng-view directive is used, which allows the application to render the view. Any changes made in the view section of the application are re
    7 min read
    What is scope in AngularJS ?
    In this article, we will see what the scope is in AngularJS and how to use Scope, along with understanding its implementation through the examples. The Scope in AngularJS is the binding part between HTML (view) and JavaScript (controller) and it is a built-in object. It contains application data and
    4 min read
    What is Angular Expression ?
    Angular is a great, reusable UI (User Interface) library for developers that help in building attractive, and steady web pages and web application. In this article, we will learn about Angular expression. Table of Content Angular ExpressionDifferent Use Cases of Angular ExpressionsSyntaxApproach Ang
    4 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences