SlideShare a Scribd company logo
ngularJS features
by Alexey Migutsky
all links are on the last slide
…and related gotchas
1. SCOPE
In scope we trust [1]
Scope is created
$rootScope
(always there)
ng-repeat
(for each iteration, inherits)
ng-include
(inherits)
ng-switch
(inherits)
ng-if
(when creating element)
ng-controller
(inherits)
ng-model
(inherits, thro implicit controller)
ng-view
(inherits, thro controller)
directive with scope:true
(inherits)
directive with transclude:true
(inherits, sibling)
directive with scope: {}
(does not inherit)
Scope is not created
directive with scope: false
(default value)
All directives, not mentioned on
the previous slide
Angular always tracks child-parent relationships,
even without inheritance
but $parent referencing is bad!
There can be only 1 scope per 1 element [2]
Directives are not mixins 
Isolated scope can isolate non-isolated scopes on the same element
Transcluded scope is sibling to directive’s scope
$parent
directive’s scope
transcluded $scope
2. DIGESTING
Run, $digest, run! [3]
5 angularjs features
Do not use $digest, use $apply in directives.
$digest is a single run, not the full cycle
$watch expression is called in $scope’s context!
In the expression this will refer to the $scope!
Do not use $watch with property getters without binding.
$digest event propagates inside isolated scopes!
The change in parent scope will trigger isolated watchers
Use events to handle ‘model changes’ sparingly [4]
Use $watch instead.
Digest cycle is fast…
…until you write bloated $watch exressions.
Watchtower [5] comes to the rescue!
3. DATABINDING
My name is Bind, Data Bind [6]
Expressions are JavaScript-like code
In case of emergency use $eval() and not eval()
Expressions have no flow control
Great decision for templates!
Expressions are evaluated against current scope.
Remember the $watch gotcha?
Expressions can have function call reference
You can specify parameters to be passed upon the call.
“someMethodCall( param1, param2 )”
Not very common, is it?
It should be called like this in JS:
someMethodCall( { param1 : ‘value’,
param2: ‘value2’
})
4. DEPENDENCY INJECTION
Injections are the best thing ever invented ... [7]
The only orthodoxal way to establish relationships
between components is DI.
5 angularjs features
Remember the ‘minification problem’[8]
Use array-based declarations.
Or just use ngmin [9].
AngularJS ‘runtime’ is an IoC container.
Read it like this: you should wrap 3rd party components, which are not
integrated with angular, into directives/services.
You can’t inject (use) them as is!
5. MODULARITY
True independence and freedom can only exist in doing what's right. [10]
Always use angular.module syntax
It is good for testing.
It is good for decoupling.
It helps manage dependencies.
Prefer module-per-feature approach [11]
It is good for testing.
It is good for refactoring and maintenance.
Using Angular with module loaders can be tricky
Angular ‘modules’ has a different nature.
Need some handcrafting to make modules and ‘modules’ play nicely.
Keep services/directives/modules as independent as possible.
This is #1 priority.
Use isolated scope for main directives.
Keep shared state in services.
Keep constructors in factories.
5 angularjs features
[1] In scope we trust
[2] 1 scope per 1 element
[3] Run, $digest, run!
[4] Why dirty checkings and not events?
[5] Project 'Watchtower'
[6] My name is Bind, Data Bind!
[7] Injections are the best things...
[8] Minification problem in Angular
[9] ngmin
[10] True independence and freedom
can only exist in doing what's right.
[11] module-per-feature architecture
Links
@mr_mig_by Alexey Migutsky

More Related Content

PDF
AngularJS: Overview & Key Features
PDF
AngularJS introduction
PPTX
Introduction to Angularjs
PDF
Introduction of angular js
PPTX
Angular js for beginners
PPTX
Angular js 1.3 presentation for fed nov 2014
PDF
Angularjs architecture
PDF
AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS: Overview & Key Features
AngularJS introduction
Introduction to Angularjs
Introduction of angular js
Angular js for beginners
Angular js 1.3 presentation for fed nov 2014
Angularjs architecture
AngularJS - What is it & Why is it awesome ? (with demos)

What's hot (20)

PDF
AngularJS 101 - Everything you need to know to get started
PDF
Angular js
PPTX
Angular JS - Introduction
PPTX
The AngularJS way
PPTX
Angular js
PPTX
Front end development with Angular JS
PPTX
Step by Step - AngularJS
PPTX
AngularJs (1.x) Presentation
PPTX
Angular js PPT
PPTX
AngularJs presentation
PDF
Introduction to AngularJS
PDF
AngularJS: an introduction
PPTX
Angular js 1.3 basic tutorial
PPTX
AngularJS intro
PPTX
Why angular js Framework
PPTX
Introduction to Angular js 2.0
PDF
Advanced Tips & Tricks for using Angular JS
PPTX
Introduction to AngularJS
PDF
AngularJS Basic Training
PPTX
Understanding angular js
AngularJS 101 - Everything you need to know to get started
Angular js
Angular JS - Introduction
The AngularJS way
Angular js
Front end development with Angular JS
Step by Step - AngularJS
AngularJs (1.x) Presentation
Angular js PPT
AngularJs presentation
Introduction to AngularJS
AngularJS: an introduction
Angular js 1.3 basic tutorial
AngularJS intro
Why angular js Framework
Introduction to Angular js 2.0
Advanced Tips & Tricks for using Angular JS
Introduction to AngularJS
AngularJS Basic Training
Understanding angular js
Ad

Viewers also liked (6)

PPTX
Node.js in a heterogeneous system
DOCX
Different way to share data between controllers in angular js
PPTX
DevOps in the clouds
PPT
Let your website a ride of AngularJS
PDF
Software engineering 101 - The basics you should hear about at least once
PDF
29 Essential AngularJS Interview Questions
Node.js in a heterogeneous system
Different way to share data between controllers in angular js
DevOps in the clouds
Let your website a ride of AngularJS
Software engineering 101 - The basics you should hear about at least once
29 Essential AngularJS Interview Questions
Ad

Similar to 5 angularjs features (20)

PDF
AngularJS Workshop
PPTX
Angular workshop - Full Development Guide
ODP
Angular js-crash-course
PPT
Coffee@DBG - Exploring Angular JS
ODP
AngularJs Crash Course
DOCX
angularjs_tutorial.docx
PPTX
Intro to AngularJs
PDF
AngularJS - TechTalk 3/2/2014
PPTX
AngularJS
PDF
PPTX
Practical AngularJS
PPTX
Learning AngularJS - Complete coverage of AngularJS features and concepts
PPTX
Single Page Applications Workshop Part II: Single Page Applications using Ang...
PPSX
PPT
Angular js
PPTX
Angular js 1.0-fundamentals
PPTX
AngularJS.part1
PDF
5 benefits of angular js
AngularJS Workshop
Angular workshop - Full Development Guide
Angular js-crash-course
Coffee@DBG - Exploring Angular JS
AngularJs Crash Course
angularjs_tutorial.docx
Intro to AngularJs
AngularJS - TechTalk 3/2/2014
AngularJS
Practical AngularJS
Learning AngularJS - Complete coverage of AngularJS features and concepts
Single Page Applications Workshop Part II: Single Page Applications using Ang...
Angular js
Angular js 1.0-fundamentals
AngularJS.part1
5 benefits of angular js

Recently uploaded (20)

PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPT
Teaching material agriculture food technology
PDF
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
cuic standard and advanced reporting.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
NewMind AI Monthly Chronicles - July 2025
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Chapter 3 Spatial Domain Image Processing.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Teaching material agriculture food technology
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
cuic standard and advanced reporting.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Advanced methodologies resolving dimensionality complications for autism neur...
NewMind AI Monthly Chronicles - July 2025
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Understanding_Digital_Forensics_Presentation.pptx
Unlocking AI with Model Context Protocol (MCP)
Reach Out and Touch Someone: Haptics and Empathic Computing
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
GamePlan Trading System Review: Professional Trader's Honest Take
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf

5 angularjs features

  • 1. ngularJS features by Alexey Migutsky all links are on the last slide …and related gotchas
  • 2. 1. SCOPE In scope we trust [1]
  • 3. Scope is created $rootScope (always there) ng-repeat (for each iteration, inherits) ng-include (inherits) ng-switch (inherits) ng-if (when creating element) ng-controller (inherits) ng-model (inherits, thro implicit controller) ng-view (inherits, thro controller) directive with scope:true (inherits) directive with transclude:true (inherits, sibling) directive with scope: {} (does not inherit)
  • 4. Scope is not created directive with scope: false (default value) All directives, not mentioned on the previous slide
  • 5. Angular always tracks child-parent relationships, even without inheritance but $parent referencing is bad!
  • 6. There can be only 1 scope per 1 element [2] Directives are not mixins  Isolated scope can isolate non-isolated scopes on the same element
  • 7. Transcluded scope is sibling to directive’s scope $parent directive’s scope transcluded $scope
  • 10. Do not use $digest, use $apply in directives. $digest is a single run, not the full cycle
  • 11. $watch expression is called in $scope’s context! In the expression this will refer to the $scope! Do not use $watch with property getters without binding.
  • 12. $digest event propagates inside isolated scopes! The change in parent scope will trigger isolated watchers
  • 13. Use events to handle ‘model changes’ sparingly [4] Use $watch instead. Digest cycle is fast… …until you write bloated $watch exressions. Watchtower [5] comes to the rescue!
  • 14. 3. DATABINDING My name is Bind, Data Bind [6]
  • 15. Expressions are JavaScript-like code In case of emergency use $eval() and not eval()
  • 16. Expressions have no flow control Great decision for templates!
  • 17. Expressions are evaluated against current scope. Remember the $watch gotcha?
  • 18. Expressions can have function call reference You can specify parameters to be passed upon the call. “someMethodCall( param1, param2 )” Not very common, is it? It should be called like this in JS: someMethodCall( { param1 : ‘value’, param2: ‘value2’ })
  • 19. 4. DEPENDENCY INJECTION Injections are the best thing ever invented ... [7]
  • 20. The only orthodoxal way to establish relationships between components is DI.
  • 22. Remember the ‘minification problem’[8] Use array-based declarations. Or just use ngmin [9].
  • 23. AngularJS ‘runtime’ is an IoC container. Read it like this: you should wrap 3rd party components, which are not integrated with angular, into directives/services. You can’t inject (use) them as is!
  • 24. 5. MODULARITY True independence and freedom can only exist in doing what's right. [10]
  • 25. Always use angular.module syntax It is good for testing. It is good for decoupling. It helps manage dependencies.
  • 26. Prefer module-per-feature approach [11] It is good for testing. It is good for refactoring and maintenance.
  • 27. Using Angular with module loaders can be tricky Angular ‘modules’ has a different nature. Need some handcrafting to make modules and ‘modules’ play nicely.
  • 28. Keep services/directives/modules as independent as possible. This is #1 priority. Use isolated scope for main directives. Keep shared state in services. Keep constructors in factories.
  • 30. [1] In scope we trust [2] 1 scope per 1 element [3] Run, $digest, run! [4] Why dirty checkings and not events? [5] Project 'Watchtower' [6] My name is Bind, Data Bind! [7] Injections are the best things... [8] Minification problem in Angular [9] ngmin [10] True independence and freedom can only exist in doing what's right. [11] module-per-feature architecture Links @mr_mig_by Alexey Migutsky