SlideShare a Scribd company logo
AngularJS - introduction & how it works?
What	is	Angular?
client-side		MVC	framework	for	dynamic	web	apps;
perfect	for	building	CRUD	application:	data-binding,
templating,	form	validation,	routing,	dependency	injection,
reusable	components;
designed	to	be	testable:	unit-testing,	end-to-end	testing,	mocks.
Why	Angular?
1.	 The	best	Model-View-Controller	Architecture
2.	 It	works	hand-in-hand	with	HTML
3.	 Power	over	your	application
4.	 Testing	is	Easy
5.	 Team	development	it's	easy
Key	features
Declarative	HTML	approach
2	way	data	binding
reusable	components	-	directives
MVC	/	MVVM	design	pattern
dependency	injection
routing
templating
animations
form	validation
E2E	integration	testing	/	unit	testing
I18n	&	I10n
How	it	works?
<!DOCTYPE	html>
<html	ng-app="myApp">
<head>
			<title>Angular	app</title>
			<script	src="bower_components/angular/angular.js">
{{name}}
angular
			.module('myApp',	[])
			.controller('MyCtrl',	function($scope){
						$scope.name	=	'World';
			});
Plunker	Example
How	it	works?
Browser	loads	the	page	and	creates	the	DOM; 	
Browser	triggers	DOMContentLoaded	event;
Angular	looks	into	the	DOM	for	the	 ng-app	attribute	and	if
the	attribute	it's	found	Angular	will:
load	the	module	associated	with	the	directive;
create	the	application	injector;
compile	the	DOM	into	a	Live	View:
:	traverse	the	DOM	and	collect	all	of	the
directives	-	the	result	is	a	linking	function;
:		combine	the	directive	with	a	scope	and
produce	a	live	view.
Data	Binding
automatic	propagation	of	data	changes;
model	it's	the	single-source-of-truth;
digest	cycle;
the	view	it's	updated	automatically	when
the	model	is	changed;
model	is	updated	automatically	when	a
value	in	the	View	has	changed.
no	DOM	manipulation	needed.
$watch,	$apply	&	$digest
Angular	uses	some	main	components	to	implement	2	way	data
binding:
$watch;
$apply;
$digest;
dirty-checking;
Implement	your	own	data	binding	mechanism
$watch
Angular	extends	the	browser	events-loop	and	creates	the
angular-context;
Every	time	something	is	bound	in	the	html	a	 watcher	is	inserted
in	a	watch	list;
a	watcher	consist	of:
a	watch	function	that	returns	the	current	value	of
the	property	it	is	watching;
a	listener	function	that	will	be	triggered	if	a	change
happened.
the	last	value	returned	by	the	watch	function;
$watch
*	Doing	this	two	watchers	are	registered.
*	For	10	people	in	the	list	it	will	be	 	(2	*	10)	+	1	watchers	registered.
First	Name:	<input	type="text"	ng-model="user.firstName"	/>
Last	Name:	<input	type="text"	ng-model="user.lastName"	/>
<ul>
		<li	ng-repeat="user	in	userList">
				{{user.firstName}}	{{user.lastName}}
		</li>
</ul>
$digest	loop
Angular	knows	about	browser	events-loop;
when	the	browser	receives	an	event	that	can	be	handled	by
angular-context	the	$digest	loop	will	be	fired;
the	$digest	loop	is	made	from	two	smaller	loops:
$evalAsync	queue;
$watch	list;
$digest	loop
The	$digest	will	loop	trough	the	watchers	list:
It	will	check	the	current	value	returned	by	the	watch	function;
It	will	compare	the	current	value	with	the	last	value;
if	the	equality	test	fails,	it	will:
call	the	listener	function	associated	with	that	watcher;
it	will	set	the	current	value	as	last	value;
it	will	set	the	$scope	as	dirty;
If	the	$scope	is	dirty,	another	$digest	loop	is	triggered.
$apply
Angular	calls	$apply		under	the	hood	when	we	use	framework
directives	like:	ngClick,	ngModel,	ngChange	etc.
The	$apply	function	executes	expressions	in	angular
context	and	then	calls	the	$digest;
Where	to	use	$apply?
in	most	of	the	cases		in	directives	where	you	handle	events
manually;
when	you	use	3rd	party	code	that	will	change	the	$scope;
$apply
app.directive('click',	function()	{
return	{
		scope:	{
				name:	'='
		},
		link:	function(scope,	element,	attrs)	{
				element.on('click',	function()	{
						scope.$apply(function()	{
								scope.name	=	'new	name';
						});
				});
		}
}
});
Plunker	Example

More Related Content

PPTX
Intro to angular
PDF
AngularJS
PDF
Introduction to Angularjs : kishan kumar
PPTX
Introduction to AngularJS
PDF
Angular js
PPTX
AngularJs (1.x) Presentation
PPTX
Angular js 1.3 presentation for fed nov 2014
PPTX
Angular js presentation at Datacom
Intro to angular
AngularJS
Introduction to Angularjs : kishan kumar
Introduction to AngularJS
Angular js
AngularJs (1.x) Presentation
Angular js 1.3 presentation for fed nov 2014
Angular js presentation at Datacom

What's hot (20)

PDF
Introduction to Angular Js
PPTX
Angular js
PPTX
Angularjs PPT
PPTX
PPTX
Introduction to single page application with angular js
PPT
CTTDNUG ASP.NET MVC
PDF
AngularJS: Overview & Key Features
PDF
Angular Project Report
PDF
ASP.NET MVC 3
PPT
ASP .net MVC
PPTX
Introduction to AngularJS Framework
PPTX
Overview about AngularJS Framework
PDF
Angularjs tutorial
PPTX
AngularJS = Browser applications on steroids
PDF
Introduction to AngularJS
PPTX
AngularJS is awesome
PPTX
AngularJS Scopes
PPTX
Introduction to Android Programming
PPTX
The A1 "AngularJS 1 Kick Start"
PPTX
ASP .NET MVC
Introduction to Angular Js
Angular js
Angularjs PPT
Introduction to single page application with angular js
CTTDNUG ASP.NET MVC
AngularJS: Overview & Key Features
Angular Project Report
ASP.NET MVC 3
ASP .net MVC
Introduction to AngularJS Framework
Overview about AngularJS Framework
Angularjs tutorial
AngularJS = Browser applications on steroids
Introduction to AngularJS
AngularJS is awesome
AngularJS Scopes
Introduction to Android Programming
The A1 "AngularJS 1 Kick Start"
ASP .NET MVC
Ad

Viewers also liked (10)

PDF
Data binding in AngularJS, from model to view
PDF
Angular.JS - Estado Atual
PPTX
Angular js
PDF
Advanced Tips & Tricks for using Angular JS
PDF
Angular JS - Develop Responsive Single Page Application
PPTX
Sql vs NoSQL
ODP
Introduction to Angular 2
PPTX
Introduction to angular 2
PDF
Ionic 2 como ferramenta para desenvolvimento mΓ³vel
PPTX
Dynamic content with Angular
Data binding in AngularJS, from model to view
Angular.JS - Estado Atual
Angular js
Advanced Tips & Tricks for using Angular JS
Angular JS - Develop Responsive Single Page Application
Sql vs NoSQL
Introduction to Angular 2
Introduction to angular 2
Ionic 2 como ferramenta para desenvolvimento mΓ³vel
Dynamic content with Angular
Ad

Similar to AngularJS - introduction & how it works? (20)

PPTX
Valentine with Angular js - Introduction
PPTX
Dive into Angular, part 1: Introduction
DOCX
Angular js getting started
PDF
AngularJS Deep Dives (NYC GDG Apr 2013)
PPTX
Angular js anupama
PPTX
AngularJs
PPTX
ME vs WEB - AngularJS Fundamentals
PDF
Workshop 12: AngularJS Parte I
PPTX
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
PPT
introduction to Angularjs basics
PPTX
AngularJS Overview
PPTX
Angular js
PDF
PPTX
Introducing AngularJS
PDF
AngularJS Basics
PDF
One Weekend With AngularJS
PPTX
Intro to AngularJs
PPTX
Intoduction to Angularjs
PDF
Wt unit 5 client &amp; server side framework
PPTX
Angular workshop - Full Development Guide
Valentine with Angular js - Introduction
Dive into Angular, part 1: Introduction
Angular js getting started
AngularJS Deep Dives (NYC GDG Apr 2013)
Angular js anupama
AngularJs
ME vs WEB - AngularJS Fundamentals
Workshop 12: AngularJS Parte I
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
introduction to Angularjs basics
AngularJS Overview
Angular js
Introducing AngularJS
AngularJS Basics
One Weekend With AngularJS
Intro to AngularJs
Intoduction to Angularjs
Wt unit 5 client &amp; server side framework
Angular workshop - Full Development Guide

More from Alexe Bogdan (8)

PDF
Angular promises and http
PDF
Dependency Injection pattern in Angular
PDF
Client Side MVC & Angular
PDF
HTML & JavaScript Introduction
PDF
Angular custom directives
PDF
Angular server-side communication
PDF
Angular Promises and Advanced Routing
PDF
AngularJS - dependency injection
Angular promises and http
Dependency Injection pattern in Angular
Client Side MVC & Angular
HTML & JavaScript Introduction
Angular custom directives
Angular server-side communication
Angular Promises and Advanced Routing
AngularJS - dependency injection

Recently uploaded (20)

PPTX
introduction about ICD -10 & ICD-11 ppt.pptx
PPTX
PPT_M4.3_WORKING WITH SLIDES APPLIED.pptx
PPTX
durere- in cancer tu ttresjjnklj gfrrjnrs mhugyfrd
PDF
β€œGoogle Algorithm Updates in 2025 Guide”
PDF
WebRTC in SignalWire - troubleshooting media negotiation
PPTX
Introduction to Information and Communication Technology
PPTX
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
PDF
Slides PDF The World Game (s) Eco Economic Epochs.pdf
PDF
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
Β 
PPTX
presentation_pfe-universite-molay-seltan.pptx
PPTX
Internet___Basics___Styled_ presentation
PPTX
international classification of diseases ICD-10 review PPT.pptx
PDF
πŸ’° π”πŠπ“πˆ πŠπ„πŒπ„ππ€ππ†π€π πŠπˆππ„π‘πŸ’πƒ π‡π€π‘πˆ 𝐈𝐍𝐈 πŸπŸŽπŸπŸ“ πŸ’°
Β 
PDF
Decoding a Decade: 10 Years of Applied CTI Discipline
PDF
Sims 4 Historia para lo sims 4 para jugar
PPTX
INTERNET------BASICS-------UPDATED PPT PRESENTATION
PDF
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
PDF
Testing WebRTC applications at scale.pdf
PPTX
innovation process that make everything different.pptx
PDF
The Internet -By the Numbers, Sri Lanka Edition
Β 
introduction about ICD -10 & ICD-11 ppt.pptx
PPT_M4.3_WORKING WITH SLIDES APPLIED.pptx
durere- in cancer tu ttresjjnklj gfrrjnrs mhugyfrd
β€œGoogle Algorithm Updates in 2025 Guide”
WebRTC in SignalWire - troubleshooting media negotiation
Introduction to Information and Communication Technology
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
Slides PDF The World Game (s) Eco Economic Epochs.pdf
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
Β 
presentation_pfe-universite-molay-seltan.pptx
Internet___Basics___Styled_ presentation
international classification of diseases ICD-10 review PPT.pptx
πŸ’° π”πŠπ“πˆ πŠπ„πŒπ„ππ€ππ†π€π πŠπˆππ„π‘πŸ’πƒ π‡π€π‘πˆ 𝐈𝐍𝐈 πŸπŸŽπŸπŸ“ πŸ’°
Β 
Decoding a Decade: 10 Years of Applied CTI Discipline
Sims 4 Historia para lo sims 4 para jugar
INTERNET------BASICS-------UPDATED PPT PRESENTATION
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
Testing WebRTC applications at scale.pdf
innovation process that make everything different.pptx
The Internet -By the Numbers, Sri Lanka Edition
Β 

AngularJS - introduction & how it works?