SlideShare a Scribd company logo
AngularJS
• What is AngularJS
• AngularJS main components
– View / Controller / Module / Scope
• Scope Inheritance.
• Two way data binding
– $watch / $digest / $apply
– Dirty Checking
• DI - Dependence Injection
• $provider vs $factory vs $service
What is AngularJS
• Javascript Front-end Framework (100% Javascript
& 100% client side)
• For building dynamic web apps.
• Angular is what HTML would have been, had it
been designed for applications.
• HTML is a great declarative language for static
documents.
• But It does not contain much in the way of
creating applications.
• It lets you use HTML as template language.
• It lets you extend HTML’s syntax to express
your application’s components clearly and
succinctly.
• Angular's data binding and dependency
injection eliminate much of the code you
would otherwise have to write
• MVC design parttern to organize codes.
Traditional Solution
HTML
<37% LOC
JavaScript
>63% LOC
AngularJS solution
HTML
<59% LOC
JavaScript
>41% LOC
Model
MVC
View
Controller
Template
Template -> View
Template
Compile
View - DOM
Directive
• AngularJs is what HTML could have been if it had
been designed for web application.
• HTML is a markup language for describing web
document.
Directive
• A directive is a maker on a DOM element that tells
Angular to run or reference some JS code to:
– Attach a specified behaviors to that DOM.
– Transform the DOM on the fly.
<map id="map_canvas" x="46.8765" y="-3.32910"></map>
Expression
• Allow you to insert dynamic values into your
html.
I am number {{0 + 1}} -> I am number 1
{{"hello" + " you"}} -> hello you
{{“Hi," + user.name}} -> Hi, Tom
Modules
• A module is a collection of services, directives,
controllers, filters, and configuration
information
• Where we write pieces of our angular
application.
• Makes our code more maintainable, testable
and readable.
Module
Controller
• Controller is a JavaScript function.
• Controller contains business logic behind the
application to decorate the scope with
functions and data.
• The ngController directive specifies a
Controller class.
Controller
Scope
• scope is an object that refers to the
application model.
• Scope is the glue between application
controller and the view.
• Scope provide $watch to observe model
mutations.
Controller
Model
Out of scope
Ng-controller alias
Angular Scope Inheritance
• In AngularJS, a child scope normally
prototypically inherits from its parent scope
• Child scope:
– scope of child controller
– Child of $rootscope
– New child scope is created by build-in directive
(ng-repeat, ng-switch, ng-view and ng-include)
• Isolate scope: no inherits from parent.
Angular Scope Inheritance
Hides/shadows property issue
• Six data types that are primitives:
– Boolean
– Null
– Undefined
– Number
– String
– Symbol (new in ECMAScript 6)
• Change a primitive value defined on the parent
scope from inside the child scope.
childScope.aString === 'parent string'
childScope.anArray[1] === 20
childScope.anObject.property1 === 'parent prop1'
childScope.aFunction() === 'parent output'
childScope.aString = 'child string'
A new aString property is added to the childScope.
-> This new property hides/shadows the parentScope property with the same
name
childScope.anArray = [100, 555]
childScope.anObject = { name: 'Mark', country: 'USA' }
workarounds
• If you really want/need to use a primitive,
there are two workarounds:
– Use $parent.parentScopeProperty in the child
scope. This will prevent the child scope from
creating its own property.
– Define a function on the parent scope, and call it
from the child, passing the primitive value up to
the parent (not always possible)
Data binding
• Changes to the model are NOT automatically reflected in the view.
• Any changes the view are NOT automatically reflected in the model.
After the merge occurs:
Two way data binding
1. The template is compiled on the browser.
2. The compilation step produces a live view.
3. Any changes to the view are immediately reflected in the model,
4. and any changes in the model are propagated to the view.
$scope.$watch
• When you create a data binding from somewhere
in your view to a variable on the $scope object,
AngularJS creates a "watch" internally.
• A watch means that AngularJS watches changes
in the variable on the $scope object.
• Watches are created using the $scope.$watch()
• Each $watch be inserted into $watch list
$scope.$watch
$scope.$digest
• Use to checks if there are any changes to all the
variables watched by all the $scopes.
• If a watched variable has changed, a
corresponding listener function is called.
• This listener function does what it need to do:
• Example: changing an HTML text to reflect the
new value of the watched variable.
• => the $digest() function is what triggers the data
binding to update.
$digest loop
• Loop through $watch list and compare old vs new value:
– Hey $watch, what is your value?
• It is 9
– Alright, has it changed?
• No, sir.
– (nothing happens with this one, so it moves to the next)
– You, what is your value?
• It is Foo.
– Has it changed?
• Yes, it was Bar.
– (good, we have a DOM to be updated)
– This continues until every $watch has been checked.
• When the $digest loop finishes, the DOM makes the changes.
=> Dirty Checking
One more
Time
Baby!
Dirty checking
• if the loop runs more than 10 times, it will
throw an exception to prevent infinite loops
Dirty Checking
$scope.$apply
• used to execute some code, and then
call $scope.$digest() after that.
• Called when an event is fire
When angular doesn’t use $apply for us
• Native event that is not wrapped into $apply
call.
• Use directly jQuery.ajax()
=> Whenever possible, use AngularJS services
instead of native
Using $watch for our own stuff
• $watch(watchExpression, listener);
-> $watch will only shallow check the referenced value by default.
• $watch(watchExpression, listener, true);
-> When deep-watching an object, angular will follow all references to other
objects.
-> May be results in an infinite loop.
• $watchCollection(obj, listener);
-> deep-watching array.
• Dirty checking can be done with three strategies: By reference, by
collection contents, and by value
• ng-model does not do a deep watch
DI - Dependence Injection
• Dependency injection means giving an object
its instance variables. Really. That's it.
• Instead of having it construct them itself.
• Dependencies can be injected into objects by
many means (such as constructor injection or
setter injection)
DI in AngularJS
The Provider ($provide)
• Injectable things - services
• Services are defined by things called providers
• Providers are created by $provide service.
• The $provide service is responsible for telling
Angular how to create new services.
Defining a provider
• $provide. provider(name, provider);
• $get : create a service – greeting service
Inject service
• Angular will call the greeting
provider's $get function in order to return a
new instance of the service.
Service in AngularJS
• Lazily instantiated – Angular only instantiates
a service when an application component
depends on it.
• Singletons – Each component dependent on a
service gets a reference to the single instance
generated by the service factory.
$provide.factory
• Short way to create Service.
• AngularJS is calling the exact same
code $provide.provider for us.
$provide.service
• $provide. service(name, constructor)
Common way
Provider vs Factory vs Service
1. app.provider('c', fn); => new fn(); fn.$get()
2. app.factory('a', fn); => fn() { return obj }
3. app.service('b', fn); => new fn()
Config & Run phases
angular.module('myModule', [])
. config(function(injectables){ // provider / $provide and $injector
// This is an example of config block.
// You can have as many of these as you want.
// You can only inject Providers (not instances)
// into config blocks.
})
. run(function(injectables) { // instance-injector
// This is an example of a run block.
// You can have as many of these as you want.
// You can only inject instances (not Providers) into run blocks
});
The Injector ($injector)
• The injector is responsible for actually creating
instances of our services using the code we
provided via $provide
$injector
greetingProvider
$httpProvider
$routeProvider
I need “greeting” service
Create instance
“greeting” service instance
var greeting = $injector.get('greeting');
$injector
• Each AngularJS application has a single $injector that
gets created when the application first starts.
• You can inject services into any function that is
called with$injector.invoke. This includes:
– controller definition functions
– directive definition functions
– filter definition functions
– the $get methods of providers (aka
the factory definition functions)
• Custom Directive.
• AngularJS bootstrap life cycle.

More Related Content

What's hot

Angular 9
Angular 9 Angular 9
Angular 9
Raja Vishnu
 
Angular
AngularAngular
Angular
khoado2002
 
Angular Basics.pptx
Angular Basics.pptxAngular Basics.pptx
Angular Basics.pptx
AshokKumar616995
 
Routing & Navigating Pages in Angular 2
Routing & Navigating Pages in Angular 2Routing & Navigating Pages in Angular 2
Routing & Navigating Pages in Angular 2
Knoldus Inc.
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
WebStackAcademy
 
What is Angular?
What is Angular?What is Angular?
What is Angular?
Albiorix Technology
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get started
Stéphane Bégaudeau
 
Angular kickstart slideshare
Angular kickstart   slideshareAngular kickstart   slideshare
Angular kickstart slideshare
SaleemMalik52
 
What’s New in Angular 14?
What’s New in Angular 14?What’s New in Angular 14?
What’s New in Angular 14?
Albiorix Technology
 
Introduction to Angular 2
Introduction to Angular 2Introduction to Angular 2
Introduction to Angular 2
Knoldus Inc.
 
Angular Advanced Routing
Angular Advanced RoutingAngular Advanced Routing
Angular Advanced Routing
Laurent Duveau
 
Angular 8
Angular 8 Angular 8
Angular 8
Sunil OS
 
Angular data binding
Angular data binding Angular data binding
Angular data binding
Sultan Ahmed
 
Angular 10 course_content
Angular 10 course_contentAngular 10 course_content
Angular 10 course_content
NAVEENSAGGAM1
 
Angular tutorial
Angular tutorialAngular tutorial
Angular tutorial
Rohit Gupta
 
Sharing Data Between Angular Components
Sharing Data Between Angular ComponentsSharing Data Between Angular Components
Sharing Data Between Angular Components
Squash Apps Pvt Ltd
 
Angular Data Binding
Angular Data BindingAngular Data Binding
Angular Data Binding
Jennifer Estrada
 
Angular Dependency Injection
Angular Dependency InjectionAngular Dependency Injection
Angular Dependency Injection
Nir Kaufman
 
Understanding angular js
Understanding angular jsUnderstanding angular js
Understanding angular js
Aayush Shrestha
 
Angular
AngularAngular

What's hot (20)

Angular 9
Angular 9 Angular 9
Angular 9
 
Angular
AngularAngular
Angular
 
Angular Basics.pptx
Angular Basics.pptxAngular Basics.pptx
Angular Basics.pptx
 
Routing & Navigating Pages in Angular 2
Routing & Navigating Pages in Angular 2Routing & Navigating Pages in Angular 2
Routing & Navigating Pages in Angular 2
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
 
What is Angular?
What is Angular?What is Angular?
What is Angular?
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get started
 
Angular kickstart slideshare
Angular kickstart   slideshareAngular kickstart   slideshare
Angular kickstart slideshare
 
What’s New in Angular 14?
What’s New in Angular 14?What’s New in Angular 14?
What’s New in Angular 14?
 
Introduction to Angular 2
Introduction to Angular 2Introduction to Angular 2
Introduction to Angular 2
 
Angular Advanced Routing
Angular Advanced RoutingAngular Advanced Routing
Angular Advanced Routing
 
Angular 8
Angular 8 Angular 8
Angular 8
 
Angular data binding
Angular data binding Angular data binding
Angular data binding
 
Angular 10 course_content
Angular 10 course_contentAngular 10 course_content
Angular 10 course_content
 
Angular tutorial
Angular tutorialAngular tutorial
Angular tutorial
 
Sharing Data Between Angular Components
Sharing Data Between Angular ComponentsSharing Data Between Angular Components
Sharing Data Between Angular Components
 
Angular Data Binding
Angular Data BindingAngular Data Binding
Angular Data Binding
 
Angular Dependency Injection
Angular Dependency InjectionAngular Dependency Injection
Angular Dependency Injection
 
Understanding angular js
Understanding angular jsUnderstanding angular js
Understanding angular js
 
Angular
AngularAngular
Angular
 

Viewers also liked

AngularJS Basics with Example
AngularJS Basics with ExampleAngularJS Basics with Example
AngularJS Basics with Example
Sergey Bolshchikov
 
Angular Deep Directive
Angular Deep DirectiveAngular Deep Directive
Angular Deep Directive
Henry Tao
 
Custom AngularJS Directives
Custom AngularJS DirectivesCustom AngularJS Directives
Custom AngularJS Directives
yprodev
 
Step by Step - AngularJS
Step by Step - AngularJSStep by Step - AngularJS
Step by Step - AngularJS
Infragistics
 
AngularJS custom directive
AngularJS custom directiveAngularJS custom directive
AngularJS custom directive
Nascenia IT
 
Building Custom AngularJS Directives - A Step-by-Step Guide - Dan Wahlin | Fa...
Building Custom AngularJS Directives - A Step-by-Step Guide - Dan Wahlin | Fa...Building Custom AngularJS Directives - A Step-by-Step Guide - Dan Wahlin | Fa...
Building Custom AngularJS Directives - A Step-by-Step Guide - Dan Wahlin | Fa...
FalafelSoftware
 
Scope in AngularJs
Scope in AngularJsScope in AngularJs
Scope in AngularJs
Thien To
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
Jussi Pohjolainen
 
AngularJS Compile Process
AngularJS Compile ProcessAngularJS Compile Process
AngularJS Compile Process
Eyal Vardi
 
AngularJS Architecture
AngularJS ArchitectureAngularJS Architecture
AngularJS Architecture
Eyal Vardi
 
Advanced AngularJS Concepts
Advanced AngularJS ConceptsAdvanced AngularJS Concepts
Advanced AngularJS Concepts
Kyle Hodgson
 

Viewers also liked (12)

AngularJS Basics with Example
AngularJS Basics with ExampleAngularJS Basics with Example
AngularJS Basics with Example
 
Introduction to Angularjs
Introduction to AngularjsIntroduction to Angularjs
Introduction to Angularjs
 
Angular Deep Directive
Angular Deep DirectiveAngular Deep Directive
Angular Deep Directive
 
Custom AngularJS Directives
Custom AngularJS DirectivesCustom AngularJS Directives
Custom AngularJS Directives
 
Step by Step - AngularJS
Step by Step - AngularJSStep by Step - AngularJS
Step by Step - AngularJS
 
AngularJS custom directive
AngularJS custom directiveAngularJS custom directive
AngularJS custom directive
 
Building Custom AngularJS Directives - A Step-by-Step Guide - Dan Wahlin | Fa...
Building Custom AngularJS Directives - A Step-by-Step Guide - Dan Wahlin | Fa...Building Custom AngularJS Directives - A Step-by-Step Guide - Dan Wahlin | Fa...
Building Custom AngularJS Directives - A Step-by-Step Guide - Dan Wahlin | Fa...
 
Scope in AngularJs
Scope in AngularJsScope in AngularJs
Scope in AngularJs
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
AngularJS Compile Process
AngularJS Compile ProcessAngularJS Compile Process
AngularJS Compile Process
 
AngularJS Architecture
AngularJS ArchitectureAngularJS Architecture
AngularJS Architecture
 
Advanced AngularJS Concepts
Advanced AngularJS ConceptsAdvanced AngularJS Concepts
Advanced AngularJS Concepts
 

Similar to AngularJs presentation

Angular js
Angular jsAngular js
Angular js
Baldeep Sohal
 
AngularJs Crash Course
AngularJs Crash CourseAngularJs Crash Course
AngularJs Crash Course
Keith Bloomfield
 
AngularJS Scopes
AngularJS ScopesAngularJS Scopes
AngularJS Scopes
Mohamed Elkhodary
 
Angular js 1.0-fundamentals
Angular js 1.0-fundamentalsAngular js 1.0-fundamentals
Angular js 1.0-fundamentals
Venkatesh Narayanan
 
Angularjs
AngularjsAngularjs
Angularjs
Sabin Tamrakar
 
AngularJS Beginners Workshop
AngularJS Beginners WorkshopAngularJS Beginners Workshop
AngularJS Beginners Workshop
Sathish VJ
 
Angular js for Beginnners
Angular js for BeginnnersAngular js for Beginnners
Angular js for Beginnners
Santosh Kumar Kar
 
Integrating AngularJS into the Campus CMS
Integrating AngularJS into the Campus CMSIntegrating AngularJS into the Campus CMS
Integrating AngularJS into the Campus CMS
Tom Borger
 
Angularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetupAngularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetupGoutam Dey
 
Intoduction to Angularjs
Intoduction to AngularjsIntoduction to Angularjs
Intoduction to Angularjs
Gaurav Agrawal
 
AngularJS in practice
AngularJS in practiceAngularJS in practice
AngularJS in practice
Eugene Fidelin
 
Angular js
Angular jsAngular js
Angular js
Hritesh Saha
 
angularjsmeetup-150303044616-conversion-gate01
angularjsmeetup-150303044616-conversion-gate01angularjsmeetup-150303044616-conversion-gate01
angularjsmeetup-150303044616-conversion-gate01Teo E
 
Angular js meetup
Angular js meetupAngular js meetup
Angular js meetup
Pierre-Yves Gicquel
 
Angularjs Basics
Angularjs BasicsAngularjs Basics
Angularjs Basics
Anuradha Bandara
 
Workshop 14: AngularJS Parte III
Workshop 14: AngularJS Parte IIIWorkshop 14: AngularJS Parte III
Workshop 14: AngularJS Parte III
Visual Engineering
 
Coffee@DBG - Exploring Angular JS
Coffee@DBG - Exploring Angular JSCoffee@DBG - Exploring Angular JS
Coffee@DBG - Exploring Angular JS
Deepu S Nath
 

Similar to AngularJs presentation (20)

Angular js
Angular jsAngular js
Angular js
 
AngularJs Crash Course
AngularJs Crash CourseAngularJs Crash Course
AngularJs Crash Course
 
AngularJS Scopes
AngularJS ScopesAngularJS Scopes
AngularJS Scopes
 
Angular js
Angular jsAngular js
Angular js
 
Angular js 1.0-fundamentals
Angular js 1.0-fundamentalsAngular js 1.0-fundamentals
Angular js 1.0-fundamentals
 
Angularjs
AngularjsAngularjs
Angularjs
 
AngularJS Beginners Workshop
AngularJS Beginners WorkshopAngularJS Beginners Workshop
AngularJS Beginners Workshop
 
Angular js for Beginnners
Angular js for BeginnnersAngular js for Beginnners
Angular js for Beginnners
 
Integrating AngularJS into the Campus CMS
Integrating AngularJS into the Campus CMSIntegrating AngularJS into the Campus CMS
Integrating AngularJS into the Campus CMS
 
Angularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetupAngularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetup
 
Intoduction to Angularjs
Intoduction to AngularjsIntoduction to Angularjs
Intoduction to Angularjs
 
AngularJS in practice
AngularJS in practiceAngularJS in practice
AngularJS in practice
 
Angular js
Angular jsAngular js
Angular js
 
Angular js
Angular jsAngular js
Angular js
 
Angular js
Angular jsAngular js
Angular js
 
angularjsmeetup-150303044616-conversion-gate01
angularjsmeetup-150303044616-conversion-gate01angularjsmeetup-150303044616-conversion-gate01
angularjsmeetup-150303044616-conversion-gate01
 
Angular js meetup
Angular js meetupAngular js meetup
Angular js meetup
 
Angularjs Basics
Angularjs BasicsAngularjs Basics
Angularjs Basics
 
Workshop 14: AngularJS Parte III
Workshop 14: AngularJS Parte IIIWorkshop 14: AngularJS Parte III
Workshop 14: AngularJS Parte III
 
Coffee@DBG - Exploring Angular JS
Coffee@DBG - Exploring Angular JSCoffee@DBG - Exploring Angular JS
Coffee@DBG - Exploring Angular JS
 

Recently uploaded

Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 

Recently uploaded (20)

Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 

AngularJs presentation

  • 2. • What is AngularJS • AngularJS main components – View / Controller / Module / Scope • Scope Inheritance. • Two way data binding – $watch / $digest / $apply – Dirty Checking • DI - Dependence Injection • $provider vs $factory vs $service
  • 3. What is AngularJS • Javascript Front-end Framework (100% Javascript & 100% client side) • For building dynamic web apps. • Angular is what HTML would have been, had it been designed for applications. • HTML is a great declarative language for static documents. • But It does not contain much in the way of creating applications.
  • 4. • It lets you use HTML as template language. • It lets you extend HTML’s syntax to express your application’s components clearly and succinctly. • Angular's data binding and dependency injection eliminate much of the code you would otherwise have to write • MVC design parttern to organize codes.
  • 10. Directive • AngularJs is what HTML could have been if it had been designed for web application. • HTML is a markup language for describing web document.
  • 11. Directive • A directive is a maker on a DOM element that tells Angular to run or reference some JS code to: – Attach a specified behaviors to that DOM. – Transform the DOM on the fly. <map id="map_canvas" x="46.8765" y="-3.32910"></map>
  • 12.
  • 13. Expression • Allow you to insert dynamic values into your html. I am number {{0 + 1}} -> I am number 1 {{"hello" + " you"}} -> hello you {{“Hi," + user.name}} -> Hi, Tom
  • 14. Modules • A module is a collection of services, directives, controllers, filters, and configuration information • Where we write pieces of our angular application. • Makes our code more maintainable, testable and readable.
  • 16. Controller • Controller is a JavaScript function. • Controller contains business logic behind the application to decorate the scope with functions and data. • The ngController directive specifies a Controller class.
  • 18.
  • 19. Scope • scope is an object that refers to the application model. • Scope is the glue between application controller and the view. • Scope provide $watch to observe model mutations.
  • 21.
  • 24.
  • 25.
  • 26. Angular Scope Inheritance • In AngularJS, a child scope normally prototypically inherits from its parent scope • Child scope: – scope of child controller – Child of $rootscope – New child scope is created by build-in directive (ng-repeat, ng-switch, ng-view and ng-include) • Isolate scope: no inherits from parent.
  • 28. Hides/shadows property issue • Six data types that are primitives: – Boolean – Null – Undefined – Number – String – Symbol (new in ECMAScript 6) • Change a primitive value defined on the parent scope from inside the child scope.
  • 29. childScope.aString === 'parent string' childScope.anArray[1] === 20 childScope.anObject.property1 === 'parent prop1' childScope.aFunction() === 'parent output'
  • 30. childScope.aString = 'child string' A new aString property is added to the childScope. -> This new property hides/shadows the parentScope property with the same name
  • 31. childScope.anArray = [100, 555] childScope.anObject = { name: 'Mark', country: 'USA' }
  • 32. workarounds • If you really want/need to use a primitive, there are two workarounds: – Use $parent.parentScopeProperty in the child scope. This will prevent the child scope from creating its own property. – Define a function on the parent scope, and call it from the child, passing the primitive value up to the parent (not always possible)
  • 33. Data binding • Changes to the model are NOT automatically reflected in the view. • Any changes the view are NOT automatically reflected in the model. After the merge occurs:
  • 34. Two way data binding 1. The template is compiled on the browser. 2. The compilation step produces a live view. 3. Any changes to the view are immediately reflected in the model, 4. and any changes in the model are propagated to the view.
  • 35. $scope.$watch • When you create a data binding from somewhere in your view to a variable on the $scope object, AngularJS creates a "watch" internally. • A watch means that AngularJS watches changes in the variable on the $scope object. • Watches are created using the $scope.$watch() • Each $watch be inserted into $watch list
  • 37. $scope.$digest • Use to checks if there are any changes to all the variables watched by all the $scopes. • If a watched variable has changed, a corresponding listener function is called. • This listener function does what it need to do: • Example: changing an HTML text to reflect the new value of the watched variable. • => the $digest() function is what triggers the data binding to update.
  • 38. $digest loop • Loop through $watch list and compare old vs new value: – Hey $watch, what is your value? • It is 9 – Alright, has it changed? • No, sir. – (nothing happens with this one, so it moves to the next) – You, what is your value? • It is Foo. – Has it changed? • Yes, it was Bar. – (good, we have a DOM to be updated) – This continues until every $watch has been checked. • When the $digest loop finishes, the DOM makes the changes. => Dirty Checking One more Time Baby!
  • 39. Dirty checking • if the loop runs more than 10 times, it will throw an exception to prevent infinite loops
  • 41. $scope.$apply • used to execute some code, and then call $scope.$digest() after that. • Called when an event is fire
  • 42.
  • 43. When angular doesn’t use $apply for us • Native event that is not wrapped into $apply call. • Use directly jQuery.ajax() => Whenever possible, use AngularJS services instead of native
  • 44. Using $watch for our own stuff • $watch(watchExpression, listener); -> $watch will only shallow check the referenced value by default. • $watch(watchExpression, listener, true); -> When deep-watching an object, angular will follow all references to other objects. -> May be results in an infinite loop. • $watchCollection(obj, listener); -> deep-watching array. • Dirty checking can be done with three strategies: By reference, by collection contents, and by value • ng-model does not do a deep watch
  • 45.
  • 46. DI - Dependence Injection • Dependency injection means giving an object its instance variables. Really. That's it. • Instead of having it construct them itself. • Dependencies can be injected into objects by many means (such as constructor injection or setter injection)
  • 48. The Provider ($provide) • Injectable things - services • Services are defined by things called providers • Providers are created by $provide service. • The $provide service is responsible for telling Angular how to create new services.
  • 49. Defining a provider • $provide. provider(name, provider); • $get : create a service – greeting service
  • 50. Inject service • Angular will call the greeting provider's $get function in order to return a new instance of the service.
  • 51. Service in AngularJS • Lazily instantiated – Angular only instantiates a service when an application component depends on it. • Singletons – Each component dependent on a service gets a reference to the single instance generated by the service factory.
  • 52. $provide.factory • Short way to create Service. • AngularJS is calling the exact same code $provide.provider for us.
  • 55. Provider vs Factory vs Service 1. app.provider('c', fn); => new fn(); fn.$get() 2. app.factory('a', fn); => fn() { return obj } 3. app.service('b', fn); => new fn()
  • 56. Config & Run phases angular.module('myModule', []) . config(function(injectables){ // provider / $provide and $injector // This is an example of config block. // You can have as many of these as you want. // You can only inject Providers (not instances) // into config blocks. }) . run(function(injectables) { // instance-injector // This is an example of a run block. // You can have as many of these as you want. // You can only inject instances (not Providers) into run blocks });
  • 57. The Injector ($injector) • The injector is responsible for actually creating instances of our services using the code we provided via $provide $injector greetingProvider $httpProvider $routeProvider I need “greeting” service Create instance “greeting” service instance var greeting = $injector.get('greeting');
  • 58. $injector • Each AngularJS application has a single $injector that gets created when the application first starts. • You can inject services into any function that is called with$injector.invoke. This includes: – controller definition functions – directive definition functions – filter definition functions – the $get methods of providers (aka the factory definition functions)
  • 59.
  • 60. • Custom Directive. • AngularJS bootstrap life cycle.

Editor's Notes

  1. https://github.com/angular/angular.js/wiki/Understanding-Scopes http://jsfiddle.net/5qjLd/
  2. Example
  3. Example http://tech.small-improvements.com/2014/06/11/deep-watching-circular-data-structures-in-angular/
  4. http://www.jamesshore.com/Blog/Dependency-Injection-Demystified.html