SlideShare a Scribd company logo
1 of 28
Download to read offline
AngularJS Exposed: Deep Dives
Nitya Narasimhan
@nitya
NYC GTUG Meetup
April 23, 2013
AngularJS (breaking it down..)
¤  1: Introduced (Feb) = bird’s eye view (what + why)
¤  2: Exposed (Apr) = deep dives (concepts in code)
¤  3: Applied (??) = end-to-end app (routes, promises, tests)
¤  4: Extended (??) = advanced topics (Batarang, Karma, ..)
¤  Other??
Bird’s Eye View (Recap)
¤  Client-side JavaScript Framework (OSS Google, 2009)
¤  Advocates Model-View-* architecture for web apps
¤  “HTML enhanced for web apps” (CRUD, single-page)
¤  Directives = Declarative view, Imperative behavior
¤  Scope = Transparent 2-way data binding
¤  Plays nice with others (pure JavaScript, clear boundary)
The “Declarative” Difference
“Static”
View
“Dynamic”
View
Variable = user input
Fixed = string literal
View
(HTML)
Using jQuery Using AngularJS
Behavior
(JavaScript)
No DOM Wrangling needed
2-way Data Binding (in MVC)
JavaScript
UserEvents
ServerEvents
HTML
Tightly
coupled
by logic
Decoupled
with scope
Deep Dives (Today)
¤  Startup (bootstrapping)
¤  Runtime (event handling)
¤  View Templates (HTML ++)
¤  MV-* Philosophy
¤  Binding ($scope context)
¤  Injection (Dependency)
¤  API & Modules
¤  Directives
¤  Services
¤  Filters
¤  Types
¤  Global APIs
¤  Workflow (Seed + Yeoman)
¤  Testing (BDD + Karma)
Bootstrapping: Angular ‘injector’
¤  Declare a static view (HTML)
¤  Identify ‘root’ element for the
dynamic view (ng-app)
¤  Angular treats rooted ‘tree’
as your web-app template
¤  Identifies associated module,
configures $injector service
¤  It creates $scope object to
maintain application state
¤  It uses $compile service to
process AngularJS markup
and render dynamic DOM
JSFiddle-4: Configuring Module
Runtime: Angular ‘interceptor’
¤  Browser event (initiated by
user, network, timer) occurs
¤  Enters JavaScript context to
execute event callbacks
¤  Exits JavaScript context and
renders modified DOM (view)
¤  Angular modifies event flow
to enter custom $digest loop
¤  $eval executes async tasks
¤  $watch evaluates expressions
to detect & process changes
¤  Exits loop when state stabilizes Angular context entry can be explicit (call
$apply) or implicit (Angular operation)
View Templates: HTML Enhanced
¤  “Template” boundaries defined by ng-app
¤  declarative specification of view (static DOM)
¤  compiled at runtime using model + controller (to render dynamic DOM)
¤  consists of standard elements (HTML, CSS) + angular-enhanced elements
¤  Angular-Enhanced Elements
¤  Directive – augmenting attribute or reusable DOM element
¤  Markup – “{{ }}” notation used to bind expressions to elements
¤  Expressions are processed by $parse, can include JS-like code
¤  Filters – “ | “ notation used to format data for display (chain-able)
¤  Form Controls – declarative validation, view manipulation
JSFiddle-2: “Hello “
JSFiddle-3: Form Validation
Data Binding: $scope as context
¤  Stores application state (data
model), links view-controller
¤  Detects data changes to
attached models ($watch)
¤  Provides execution context to
evaluate expressions i.e., {{ }}
¤  Has nested hierarchy (DOM-like)
for accessibility and efficiency
Code shows how ‘name’ binds to
different models in different scopes Angular “2-way binding” synchronizes data
models at view and controller via $scope
JSFiddle-5: Controller context
Injection: Handling Dependency
¤  Client-server relationships
involve “dependency”
¤  Imperative: Clients “craft” the
required dependencies.
¤  Injection: Clients “declare”
dependencies; injector fulfills
them (Inversion of control)
¤  AngularJS $inject service
¤  Ex: controller($scope, $http, $dep)
¤  Provider: “core” $http service
¤  Provider: “custom” $dep service
The Hollywood Principle
“Don’t call us ---- we’ll call you”
Angular API: The Big Picture
¤  Module è Wires application together (analogous to ‘main’)
¤  Directive è Enhance HTML (transform DOM, register behaviors)
¤  Service è Injectable singletons, execute common/async tasks
¤  Filter è Data transforms for display (ornamental or reductive)
¤  Type è Core Angular objects (e.g., FormController)
¤  Global API è Core “angular.*” methods (e.g., angular.toJson)
Angular API: ‘ng’ Module & more
Modules Filters Types gl. APIsServicesDirectives
Directives: Popular usage
¤  ngInit = initialization tasks to do before executing template
¤  ngBind = replace text content of element (e.g., span)
¤  ngModel = perform 2-way data binding for an input element
¤  ngView = adds $route template to view (single page apps)
¤  ngController = assign behavior to a given scope (context)
¤  ngRepeat = auto-instantiate template per item in collection
JSFiddle-6: ng-repeat Directive
Services: Popular Usage
¤ $window = reference to browser’s window object
¤ $document = jQuery-like ref to $window document
¤ $http = server interaction tasks (via XHR or JSONP)
¤ $location = parses app location (URL in address bar)
¤ $route = deep-linking for single-page apps
¤  $routeProvider defines routes for resources
¤  $routeParams extracted from $location search/path
JSFiddle-7: $http Service
Filters: Popular Usage
¤ currency – formats number as currency (w/ symbol)
¤ date – formats to both composed, predefined strings
¤ lowercase, uppercase – transform ‘string’ case
¤ On “Arrays”, processes according to predicate
¤  orderBy – reorders array elements to suit
¤  limitTo – returns slice of array limited to specified count
¤  filter – return selected “matching” subset of array
JSFiddle-4: Custom filter
Quick Start: angular-seed (github)
Recommended Workflow: Yeoman
Scaffolding
(think ‘seed’)
Resolving
(think ‘maven’)
Running
(think ‘ant’)
Workflow: Yeoman Benefits
(Adds)
HTML5 Shiv
Scripts
Analytics
(Simplifies)
Scaffold
Test Runner
Build
Additional (new) resources
Published April 2013
Authors oversaw AngularJS
adoption at Google
Early Access Program
Brian Ford built Batarang for
AngularJS as Google intern
Questions?
Closing the loop:
¤  Twitter è @nitya or #angular-nygdg
¤  Google+ è http://gplus.to/nitya
¤  Meetup è NYC-GDG ‘comments’
¤  Feedback and questions welcome (especially to
influence content and coverage in future talks).

More Related Content

What's hot

Backbone.js
Backbone.jsBackbone.js
Backbone.jsVO Tho
 
Introduction to AJAX In WordPress
Introduction to AJAX In WordPressIntroduction to AJAX In WordPress
Introduction to AJAX In WordPressCaldera Labs
 
AngularJS Basics
AngularJS BasicsAngularJS Basics
AngularJS BasicsRavi Mone
 
Advanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JSAdvanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JSSimon Guest
 
Managing JavaScript Dependencies With RequireJS
Managing JavaScript Dependencies With RequireJSManaging JavaScript Dependencies With RequireJS
Managing JavaScript Dependencies With RequireJSDen Odell
 
Laravel 8 export data as excel file with example
Laravel 8 export data as excel file with exampleLaravel 8 export data as excel file with example
Laravel 8 export data as excel file with exampleKaty Slemon
 
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)Binary Studio
 
Introducing AngularJS
Introducing AngularJSIntroducing AngularJS
Introducing AngularJSLoc Nguyen
 
AngularJS - Architecture decisions in a large project 
AngularJS - Architecture decisionsin a large project AngularJS - Architecture decisionsin a large project 
AngularJS - Architecture decisions in a large project Elad Hirsch
 
Integrating React.js Into a PHP Application
Integrating React.js Into a PHP ApplicationIntegrating React.js Into a PHP Application
Integrating React.js Into a PHP ApplicationAndrew Rota
 
Transakcyjność w django
Transakcyjność w djangoTransakcyjność w django
Transakcyjność w djangoMarcin Baran
 
AngularJS Basics and Best Practices - CC FE &UX
AngularJS Basics and Best Practices - CC FE &UXAngularJS Basics and Best Practices - CC FE &UX
AngularJS Basics and Best Practices - CC FE &UXJWORKS powered by Ordina
 
Requirejs
RequirejsRequirejs
Requirejssioked
 
Angularjs architecture
Angularjs architectureAngularjs architecture
Angularjs architectureMichael He
 
AngularJS introduction
AngularJS introductionAngularJS introduction
AngularJS introductionTania Gonzales
 
Building a Startup Stack with AngularJS
Building a Startup Stack with AngularJSBuilding a Startup Stack with AngularJS
Building a Startup Stack with AngularJSFITC
 
Angularjs - lazy loading techniques
Angularjs - lazy loading techniques Angularjs - lazy loading techniques
Angularjs - lazy loading techniques Nir Kaufman
 

What's hot (20)

Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
Introduction to AJAX In WordPress
Introduction to AJAX In WordPressIntroduction to AJAX In WordPress
Introduction to AJAX In WordPress
 
AngularJS Basics
AngularJS BasicsAngularJS Basics
AngularJS Basics
 
Advanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JSAdvanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JS
 
Managing JavaScript Dependencies With RequireJS
Managing JavaScript Dependencies With RequireJSManaging JavaScript Dependencies With RequireJS
Managing JavaScript Dependencies With RequireJS
 
Laravel 8 export data as excel file with example
Laravel 8 export data as excel file with exampleLaravel 8 export data as excel file with example
Laravel 8 export data as excel file with example
 
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
 
Introducing AngularJS
Introducing AngularJSIntroducing AngularJS
Introducing AngularJS
 
AngularJS - Architecture decisions in a large project 
AngularJS - Architecture decisionsin a large project AngularJS - Architecture decisionsin a large project 
AngularJS - Architecture decisions in a large project 
 
Integrating React.js Into a PHP Application
Integrating React.js Into a PHP ApplicationIntegrating React.js Into a PHP Application
Integrating React.js Into a PHP Application
 
Transakcyjność w django
Transakcyjność w djangoTransakcyjność w django
Transakcyjność w django
 
AngularJS Basics and Best Practices - CC FE &UX
AngularJS Basics and Best Practices - CC FE &UXAngularJS Basics and Best Practices - CC FE &UX
AngularJS Basics and Best Practices - CC FE &UX
 
Requirejs
RequirejsRequirejs
Requirejs
 
React
React React
React
 
Angularjs architecture
Angularjs architectureAngularjs architecture
Angularjs architecture
 
The AngularJS way
The AngularJS wayThe AngularJS way
The AngularJS way
 
AngularJS introduction
AngularJS introductionAngularJS introduction
AngularJS introduction
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
Building a Startup Stack with AngularJS
Building a Startup Stack with AngularJSBuilding a Startup Stack with AngularJS
Building a Startup Stack with AngularJS
 
Angularjs - lazy loading techniques
Angularjs - lazy loading techniques Angularjs - lazy loading techniques
Angularjs - lazy loading techniques
 

Similar to AngularJS Deep Dives (NYC GDG Apr 2013)

Practical AngularJS
Practical AngularJSPractical AngularJS
Practical AngularJSWei Ru
 
Angular workshop - Full Development Guide
Angular workshop - Full Development GuideAngular workshop - Full Development Guide
Angular workshop - Full Development GuideNitin Giri
 
Angular.js Primer in Aalto University
Angular.js Primer in Aalto UniversityAngular.js Primer in Aalto University
Angular.js Primer in Aalto UniversitySC5.io
 
Angular1x and Angular 2 for Beginners
Angular1x and Angular 2 for BeginnersAngular1x and Angular 2 for Beginners
Angular1x and Angular 2 for BeginnersOswald Campesato
 
Angular.js - An introduction for the unitiated
Angular.js - An introduction for the unitiatedAngular.js - An introduction for the unitiated
Angular.js - An introduction for the unitiatedthehoagie
 
MEAN - Notes from the field (Full-Stack Development with Javascript)
MEAN - Notes from the field (Full-Stack Development with Javascript)MEAN - Notes from the field (Full-Stack Development with Javascript)
MEAN - Notes from the field (Full-Stack Development with Javascript)Chris Clarke
 
Introduction to Angular js 2.0
Introduction to Angular js 2.0Introduction to Angular js 2.0
Introduction to Angular js 2.0Nagaraju Sangam
 
AngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
AngularJs Superheroic JavaScript MVW Framework Services by Miracle StudiosAngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
AngularJs Superheroic JavaScript MVW Framework Services by Miracle StudiosLearnimtactics
 
Angular Js Get Started - Complete Course
Angular Js Get Started - Complete CourseAngular Js Get Started - Complete Course
Angular Js Get Started - Complete CourseEPAM Systems
 
Understanding angular js
Understanding angular jsUnderstanding angular js
Understanding angular jsAayush Shrestha
 

Similar to AngularJS Deep Dives (NYC GDG Apr 2013) (20)

Practical AngularJS
Practical AngularJSPractical AngularJS
Practical AngularJS
 
AngularJS Workshop
AngularJS WorkshopAngularJS Workshop
AngularJS Workshop
 
Angular js
Angular jsAngular js
Angular js
 
Angularjs Basics
Angularjs BasicsAngularjs Basics
Angularjs Basics
 
Angular workshop - Full Development Guide
Angular workshop - Full Development GuideAngular workshop - Full Development Guide
Angular workshop - Full Development Guide
 
Angular.js Primer in Aalto University
Angular.js Primer in Aalto UniversityAngular.js Primer in Aalto University
Angular.js Primer in Aalto University
 
Angular1x and Angular 2 for Beginners
Angular1x and Angular 2 for BeginnersAngular1x and Angular 2 for Beginners
Angular1x and Angular 2 for Beginners
 
Angular js
Angular jsAngular js
Angular js
 
Angular.js - An introduction for the unitiated
Angular.js - An introduction for the unitiatedAngular.js - An introduction for the unitiated
Angular.js - An introduction for the unitiated
 
MEAN - Notes from the field (Full-Stack Development with Javascript)
MEAN - Notes from the field (Full-Stack Development with Javascript)MEAN - Notes from the field (Full-Stack Development with Javascript)
MEAN - Notes from the field (Full-Stack Development with Javascript)
 
Basics of AngularJS
Basics of AngularJSBasics of AngularJS
Basics of AngularJS
 
Dive into AngularJS and directives
Dive into AngularJS and directivesDive into AngularJS and directives
Dive into AngularJS and directives
 
Angular js 2.0 beta
Angular js 2.0 betaAngular js 2.0 beta
Angular js 2.0 beta
 
Introduction to Angular js 2.0
Introduction to Angular js 2.0Introduction to Angular js 2.0
Introduction to Angular js 2.0
 
AngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
AngularJs Superheroic JavaScript MVW Framework Services by Miracle StudiosAngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
AngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
 
Angular Js Get Started - Complete Course
Angular Js Get Started - Complete CourseAngular Js Get Started - Complete Course
Angular Js Get Started - Complete Course
 
Angular
AngularAngular
Angular
 
Angular
AngularAngular
Angular
 
Angular js
Angular jsAngular js
Angular js
 
Understanding angular js
Understanding angular jsUnderstanding angular js
Understanding angular js
 

More from Nitya Narasimhan

Introduction To Dart (GDG NY Jan 2014 Meetup)
Introduction To Dart (GDG NY Jan 2014 Meetup)Introduction To Dart (GDG NY Jan 2014 Meetup)
Introduction To Dart (GDG NY Jan 2014 Meetup)Nitya Narasimhan
 
Chrome Dev Summit Highlights (NYC GDG Dec 2013)
Chrome Dev Summit Highlights (NYC GDG Dec 2013)Chrome Dev Summit Highlights (NYC GDG Dec 2013)
Chrome Dev Summit Highlights (NYC GDG Dec 2013)Nitya Narasimhan
 
The Evolution of Social Search
The Evolution of Social SearchThe Evolution of Social Search
The Evolution of Social SearchNitya Narasimhan
 

More from Nitya Narasimhan (6)

Introduction To Dart (GDG NY Jan 2014 Meetup)
Introduction To Dart (GDG NY Jan 2014 Meetup)Introduction To Dart (GDG NY Jan 2014 Meetup)
Introduction To Dart (GDG NY Jan 2014 Meetup)
 
From 'Meteor' to 'Maker'
From 'Meteor' to 'Maker'From 'Meteor' to 'Maker'
From 'Meteor' to 'Maker'
 
Chrome Dev Summit Highlights (NYC GDG Dec 2013)
Chrome Dev Summit Highlights (NYC GDG Dec 2013)Chrome Dev Summit Highlights (NYC GDG Dec 2013)
Chrome Dev Summit Highlights (NYC GDG Dec 2013)
 
MeteorJS Introduction
MeteorJS IntroductionMeteorJS Introduction
MeteorJS Introduction
 
Angular js gtg-27feb2013
Angular js gtg-27feb2013Angular js gtg-27feb2013
Angular js gtg-27feb2013
 
The Evolution of Social Search
The Evolution of Social SearchThe Evolution of Social Search
The Evolution of Social Search
 

Recently uploaded

Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 

Recently uploaded (20)

Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 

AngularJS Deep Dives (NYC GDG Apr 2013)

  • 1. AngularJS Exposed: Deep Dives Nitya Narasimhan @nitya NYC GTUG Meetup April 23, 2013
  • 2. AngularJS (breaking it down..) ¤  1: Introduced (Feb) = bird’s eye view (what + why) ¤  2: Exposed (Apr) = deep dives (concepts in code) ¤  3: Applied (??) = end-to-end app (routes, promises, tests) ¤  4: Extended (??) = advanced topics (Batarang, Karma, ..) ¤  Other??
  • 3. Bird’s Eye View (Recap) ¤  Client-side JavaScript Framework (OSS Google, 2009) ¤  Advocates Model-View-* architecture for web apps ¤  “HTML enhanced for web apps” (CRUD, single-page) ¤  Directives = Declarative view, Imperative behavior ¤  Scope = Transparent 2-way data binding ¤  Plays nice with others (pure JavaScript, clear boundary)
  • 4. The “Declarative” Difference “Static” View “Dynamic” View Variable = user input Fixed = string literal View (HTML) Using jQuery Using AngularJS Behavior (JavaScript) No DOM Wrangling needed
  • 5. 2-way Data Binding (in MVC) JavaScript UserEvents ServerEvents HTML Tightly coupled by logic Decoupled with scope
  • 6. Deep Dives (Today) ¤  Startup (bootstrapping) ¤  Runtime (event handling) ¤  View Templates (HTML ++) ¤  MV-* Philosophy ¤  Binding ($scope context) ¤  Injection (Dependency) ¤  API & Modules ¤  Directives ¤  Services ¤  Filters ¤  Types ¤  Global APIs ¤  Workflow (Seed + Yeoman) ¤  Testing (BDD + Karma)
  • 7. Bootstrapping: Angular ‘injector’ ¤  Declare a static view (HTML) ¤  Identify ‘root’ element for the dynamic view (ng-app) ¤  Angular treats rooted ‘tree’ as your web-app template ¤  Identifies associated module, configures $injector service ¤  It creates $scope object to maintain application state ¤  It uses $compile service to process AngularJS markup and render dynamic DOM
  • 9. Runtime: Angular ‘interceptor’ ¤  Browser event (initiated by user, network, timer) occurs ¤  Enters JavaScript context to execute event callbacks ¤  Exits JavaScript context and renders modified DOM (view) ¤  Angular modifies event flow to enter custom $digest loop ¤  $eval executes async tasks ¤  $watch evaluates expressions to detect & process changes ¤  Exits loop when state stabilizes Angular context entry can be explicit (call $apply) or implicit (Angular operation)
  • 10. View Templates: HTML Enhanced ¤  “Template” boundaries defined by ng-app ¤  declarative specification of view (static DOM) ¤  compiled at runtime using model + controller (to render dynamic DOM) ¤  consists of standard elements (HTML, CSS) + angular-enhanced elements ¤  Angular-Enhanced Elements ¤  Directive – augmenting attribute or reusable DOM element ¤  Markup – “{{ }}” notation used to bind expressions to elements ¤  Expressions are processed by $parse, can include JS-like code ¤  Filters – “ | “ notation used to format data for display (chain-able) ¤  Form Controls – declarative validation, view manipulation
  • 13. Data Binding: $scope as context ¤  Stores application state (data model), links view-controller ¤  Detects data changes to attached models ($watch) ¤  Provides execution context to evaluate expressions i.e., {{ }} ¤  Has nested hierarchy (DOM-like) for accessibility and efficiency Code shows how ‘name’ binds to different models in different scopes Angular “2-way binding” synchronizes data models at view and controller via $scope
  • 15. Injection: Handling Dependency ¤  Client-server relationships involve “dependency” ¤  Imperative: Clients “craft” the required dependencies. ¤  Injection: Clients “declare” dependencies; injector fulfills them (Inversion of control) ¤  AngularJS $inject service ¤  Ex: controller($scope, $http, $dep) ¤  Provider: “core” $http service ¤  Provider: “custom” $dep service The Hollywood Principle “Don’t call us ---- we’ll call you”
  • 16. Angular API: The Big Picture ¤  Module è Wires application together (analogous to ‘main’) ¤  Directive è Enhance HTML (transform DOM, register behaviors) ¤  Service è Injectable singletons, execute common/async tasks ¤  Filter è Data transforms for display (ornamental or reductive) ¤  Type è Core Angular objects (e.g., FormController) ¤  Global API è Core “angular.*” methods (e.g., angular.toJson)
  • 17. Angular API: ‘ng’ Module & more Modules Filters Types gl. APIsServicesDirectives
  • 18. Directives: Popular usage ¤  ngInit = initialization tasks to do before executing template ¤  ngBind = replace text content of element (e.g., span) ¤  ngModel = perform 2-way data binding for an input element ¤  ngView = adds $route template to view (single page apps) ¤  ngController = assign behavior to a given scope (context) ¤  ngRepeat = auto-instantiate template per item in collection
  • 20. Services: Popular Usage ¤ $window = reference to browser’s window object ¤ $document = jQuery-like ref to $window document ¤ $http = server interaction tasks (via XHR or JSONP) ¤ $location = parses app location (URL in address bar) ¤ $route = deep-linking for single-page apps ¤  $routeProvider defines routes for resources ¤  $routeParams extracted from $location search/path
  • 22. Filters: Popular Usage ¤ currency – formats number as currency (w/ symbol) ¤ date – formats to both composed, predefined strings ¤ lowercase, uppercase – transform ‘string’ case ¤ On “Arrays”, processes according to predicate ¤  orderBy – reorders array elements to suit ¤  limitTo – returns slice of array limited to specified count ¤  filter – return selected “matching” subset of array
  • 25. Recommended Workflow: Yeoman Scaffolding (think ‘seed’) Resolving (think ‘maven’) Running (think ‘ant’)
  • 26. Workflow: Yeoman Benefits (Adds) HTML5 Shiv Scripts Analytics (Simplifies) Scaffold Test Runner Build
  • 27. Additional (new) resources Published April 2013 Authors oversaw AngularJS adoption at Google Early Access Program Brian Ford built Batarang for AngularJS as Google intern
  • 28. Questions? Closing the loop: ¤  Twitter è @nitya or #angular-nygdg ¤  Google+ è http://gplus.to/nitya ¤  Meetup è NYC-GDG ‘comments’ ¤  Feedback and questions welcome (especially to influence content and coverage in future talks).