SlideShare a Scribd company logo
Angular
Vinod Kumar Kayartaya
https://vinod.co
vinod@vinod.co
What is Angular?
• Angular is a JavaScript client side framework for
creating powerful web or mobile applications
• Created and maintained by Google
• The most popular JavaScript framework as of date
• Create HTML-like elements (components)
• a combination of HTML, CSS and JavaScript
What is Angular?
• Complete re-write of AngularJS
• Component based
• No controllers or scope
• Streamlined dependency injection
• Can write apps in TypeScript, Dart or JavaScript
(ES5/ES6)
What is Angular?
• SPA (Single Page Application)
• Just one file - index.html,
• components rendered dynamically
• Cleaner code
What is Angular?
• So many options
• ES5
• CoffeeScript
• DART
• ES6 and ES7
• TypeScript
What is Angular?
• Modular
• Testable
• Maintainable
JavaScript advances
• ES6 (ES2015)
• Classes
• Modules
• Decorators
• TypeScript
• ES6 and ES7
• Strong typing
• Interfaces
TypeScript = All JavaScripts
Angular main concepts
• Module
• Component
• Template
• Data binding
• Metadata
• Service
• Directive
• Dependency injection
The App we are going to build
The App we are going to build
The App we are going to build
The App we are going to build
Component
• @Component makes a class a reusable component
• A component is a combination of data, functions,
and HTML
• Data —> state
• Function —> behaviour
• HTML —> view
bootstrapper
main.ts
AppComponent
app.component.ts
app.component.html
router-outlet
AppFooterComponent
app-footer.component.ts
app-footer.component.html
AppHeaderComponent
app-header.component.ts
app-header.component.html
ContactListComponent
contact-list.component.ts
contact-list.component.html
EditContactComponent
edit-contact.component.ts
edit-contact.component.html
ViewContactComponent
view-contact.component.ts
view-contact.component.html
An app is a tree of components
HeaderComponent
FooterComponent
router-outlet
AppRoot
An app is a tree of
components
Metadata
• Metadata is extra information which gives angular
more info
• @Component tells angular that the class is a
component
• @Directive tells angular that the class is a directive
• @Injectable, @RouteConfig, @NgModule, …
AppHeaderComponent
Importing resource from module
Decorator
Component’s state
and behaviour
defined here
Template
• Is a way to describe a view using HTML
• Templates can be included with the component
• Or as an external file reference
• Best practice is to use an HTML file
Template
Data for the template (state)
Databinding
• {{ value }} —> interpolation
• [property] = “value” —> property binding
• (event) = “handler” —> event binding
• [(ngModel)] = “property” <—> two way binding
Service
• “Substitutable objects that are wired together using
dependency injection (DI)”
• Used to share code across an application
• Lazily initialised
Directives
• A class with @Directive metadata
• Two kinds: attributes and structural
• Attribute directives alter the look or behaviour of an
existing element
• Structural directives alter the layout by adding,
removing, and/or replacing elements in the DOM
• A Component is a directive with a view
Dependency injection
• A way to supply a new instance of a class with the
fully-formed dependencies it needs
• Most dependencies are services
• Angular knows which service/s a component
depend on by looking at the types of it’s
constructor parameters
• Services are injected by an injector which uses a
Provider to create the service
injecting an instance of ContactService
injecting an instance of Http (service)
Dependency Injection
Module
• Modules are optional, but a best practice
• export tells TypeScript that the resource is a
module available for other modules
• import tells TypeScript which resource to import
from a module
• Angular comes with a collection of library modules
Module
…is basically a
Script file in a folder.
Exporting a resource
in a module…
Importing a resource
from a module…
Using router
• Four things to take care of:
1. Import RouterModule, Routes from @angular/router
2. Define the route config using RouterModule.forRoot()
3. Use routerLink on hyperlinks or buttons
4. Create a <router-outlet> to dynamically place a
component
1. Import…
import { RouterModule, Routes } from '@angular/router';
2. Define routes
3. Links…
4. Router outlet
Navigating via code
Reading router parameters
Setup
• Create a work directory and init angular-cli
• Type the command :
• ng new angular-demo-app
• It takes a long time to finish, have patience
Run
• cd in to the app directory
• Run the app
• ng serve --port 8080 -o
Angular
Angular
Angular
main.ts
src/app.module.ts
src/app/app.component.ts
src/app/app.component.html
src/index.html
Adding a new component:
ng generate component <Component-Name>
More options
• Generate components:
• ng generate component components/counter
• ng g c components/counter
• Generate service (injectables):
• ng g s services/contacts
• Generate directives:
• ng g d directives/box
• Generate pipes:
• ng g p pipes/fullname
Check out my TOP rated
Angular 7 course
• Udemy: http://bit.ly/2LsqmMa
• SkillShare: https://skl.sh/2JfpU2I
• Visit https://vinod.co for other courses like ReactJS,
MongoDB etc.

More Related Content

PDF
Spring annotation
PPTX
Angular Data Binding
PDF
Angular - Chapter 7 - HTTP Services
PDF
Angular - Chapter 2 - TypeScript Programming
PPTX
Angular Lifecycle Hooks
PPTX
Spring boot Introduction
PPT
Java script
PDF
REST APIs with Spring
Spring annotation
Angular Data Binding
Angular - Chapter 7 - HTTP Services
Angular - Chapter 2 - TypeScript Programming
Angular Lifecycle Hooks
Spring boot Introduction
Java script
REST APIs with Spring

What's hot (20)

PDF
Angular - Chapter 5 - Directives
PDF
Spring Framework - Core
PPT
C# Exceptions Handling
PDF
Html5-Web-Storage
PDF
Ngrx slides
PDF
AngularJS 101 - Everything you need to know to get started
PPT
Angular Introduction By Surekha Gadkari
PPTX
CSharp Presentation
PPTX
PPTX
Spring Boot and REST API
PDF
Introduction to Spring Boot!
PPTX
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
PDF
Basics of React Hooks.pptx.pdf
PDF
Angular - Chapter 4 - Data and Event Handling
PDF
Spring Boot
PPTX
[Final] ReactJS presentation
PPT
Spring Boot in Action
PPT
Introduction to Javascript
PPT
React js
Angular - Chapter 5 - Directives
Spring Framework - Core
C# Exceptions Handling
Html5-Web-Storage
Ngrx slides
AngularJS 101 - Everything you need to know to get started
Angular Introduction By Surekha Gadkari
CSharp Presentation
Spring Boot and REST API
Introduction to Spring Boot!
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
Basics of React Hooks.pptx.pdf
Angular - Chapter 4 - Data and Event Handling
Spring Boot
[Final] ReactJS presentation
Spring Boot in Action
Introduction to Javascript
React js
Ad

Similar to Angular (20)

PPTX
Angular js 2
PDF
Building Blocks of Angular 2 and ASP.NET Core
PPTX
Angular patterns
PDF
better-apps-angular-2-day1.pdf and home
PPTX
What's new in Angular 2?
PDF
End to-End SPA Development Using ASP.NET and AngularJS
PPT
Angular js
PPTX
Angular IO
PPT
Angular js
PPTX
Angular js 1.0-fundamentals
PPTX
Angular
PPTX
Angular 2 with typescript
PPTX
Introduction to angular with a simple but complete project
PPTX
Angular 9
PPTX
Introduction to AngularJS
PDF
Angular meetup 2 2019-08-29
PPTX
Angular js 1.3 basic tutorial
PPTX
Angular Course.pptx
PPTX
Unlimited training using Angular p_p_t
PPTX
Asp.Net MVC 5 in Arabic
Angular js 2
Building Blocks of Angular 2 and ASP.NET Core
Angular patterns
better-apps-angular-2-day1.pdf and home
What's new in Angular 2?
End to-End SPA Development Using ASP.NET and AngularJS
Angular js
Angular IO
Angular js
Angular js 1.0-fundamentals
Angular
Angular 2 with typescript
Introduction to angular with a simple but complete project
Angular 9
Introduction to AngularJS
Angular meetup 2 2019-08-29
Angular js 1.3 basic tutorial
Angular Course.pptx
Unlimited training using Angular p_p_t
Asp.Net MVC 5 in Arabic
Ad

Recently uploaded (20)

PDF
Electronic commerce courselecture one. Pdf
PDF
Encapsulation theory and applications.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Understanding_Digital_Forensics_Presentation.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
A Presentation on Artificial Intelligence
PDF
Approach and Philosophy of On baking technology
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
cuic standard and advanced reporting.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Electronic commerce courselecture one. Pdf
Encapsulation theory and applications.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
CIFDAQ's Market Insight: SEC Turns Pro Crypto
MYSQL Presentation for SQL database connectivity
Diabetes mellitus diagnosis method based random forest with bat algorithm
Understanding_Digital_Forensics_Presentation.pptx
The AUB Centre for AI in Media Proposal.docx
Spectral efficient network and resource selection model in 5G networks
Per capita expenditure prediction using model stacking based on satellite ima...
A Presentation on Artificial Intelligence
Approach and Philosophy of On baking technology
Reach Out and Touch Someone: Haptics and Empathic Computing
cuic standard and advanced reporting.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Building Integrated photovoltaic BIPV_UPV.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Unlocking AI with Model Context Protocol (MCP)
Bridging biosciences and deep learning for revolutionary discoveries: a compr...

Angular