What Is Angular How To Install It
What Is Angular How To Install It
What Is Angular How To Install It
Features of Angular
It uses components and directives.
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 comes with the Angular CLI tool.
Applications of Angular
Single-Page Applications (SPAs): Angular is particularly well-suited for building SPAs,
where a single webpage is created and content is dynamically updated as the user
interacts.
Real-Time Applications: Angular is most used in real-time applications, such as chat
applications, weather and forecasting, and live tracking systems, where immediate
updates are essential.
Enterprise Applications: Angular is commonly used for developing large-scale
enterprise applications. Its modular architecture, dependency injection, and
TypeScript support make it suitable for building complex and maintainable
applications.
Content Management Systems (CMS): Angular can be used to build custom content
management systems, providing a dynamic and responsive user interface for
managing content.
E-commerce Websites: Angular’s two-way data binding and dynamic features make it
suitable for building interactive e-commerce websites with real-time updates and
user interactions.
Dashboards and Analytics Tools: Angular is used to create interactive dashboards and
analytics tools, it helps in data visualization and crucial real-time updates.
Cross-Platform Mobile Apps: With frameworks like Ionic or NativeScript, Angular is
used to build cross-platform mobile applications for iOS and Android operating
systems.
Social Media Applications: Angular is used widely for building social media
applications with dynamic content rendering, and interactive features.
Install Node.js: Angular requires Node.js to be installed on your computer. You can
download and install Node.js from the official Node.js website:
https://node.js.org/en/download/
Install Angular CLI: Once you have installed Node.js, you can install the Angular CLI
using the following command:
Create a new Angular project: To create a new Angular project, use the following
command:
ng new my-app
This will create a new directory called my-app and generate the basic files for an
Angular project.
Start the development server: To start the development server and run your Angular
application, use the following command:
ng serve
This will start a web server on port 4200 and open your default browser to
http://localhost:4200, where you can see your running Angular application.
That's it! You have now installed Angular and created your first Angular application.
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.
Creating a Component in Angular 8:
To create a component in any angular application, follow the below steps:
Get to the angular app via your terminal.
Create a component using the following command:
ng g c <component_name>
OR
ng generate component <component_name>
Ex- ng g c Geeks For Geeks
Using a component in Angular 8:
Go to the component.html file and write the necessary HTML code.
Go to the component.css file and write the necessary CSS code.
Write the corresponding code in component.ts file.
Run the Angular app using ng serve –open
Implementation code: Please note that the name of the component in the below
code is gfg component.
gfg.component.html:
<h1>GeeksforGeeks</h1>
gfg.component.css:
h1{
color: green;
font-size: 30px;
}
gfg.component.ts:
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-gfg',
templateUrl: './gfg.component.html',
styleUrls: ['./gfg.component.css']
})
export class GfgComponent{
a ="GeeksforGeeks";
}
app.module.ts:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
@NgModule({
imports: [ BrowserModule ],
declarations: [ AppComponent, GfgComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
OUTPUT: -
Localhost: 4200
GeeksforGeeks