SlideShare a Scribd company logo
1 of 28
Download to read offline
An Introduction to
AngularJS
Falk Hartmann

November	
  7th,	
  2013
2/12/13

1

Copyright	
  2013	
  Demandware,	
  Inc.	
  Anc.	
  ther	
  ther	
  rights	
  reserved.	
  
Copyright	
  2013	
  Demandware,	
  I ll	
  o All	
  o rights	
  reserved.
My Main Areas of Expertise
•
•
•
•
•

Java
Markup Languages
Identity and Access Management
OSGi
ActionScript/MXML

Demandware
•
•
•
•

November	
  7th,	
  2013

Develops and operates an enterprise-class cloud commerce platform since 2004
160 retail brands with more than 665 sites world-wide
Offices in Jena, Burlington (MA), Munich, Paris, London
Technologies
- Java, JEE, Spring
- Oracle, MongoDB, Redis, ElasticSearch
- Demandware Script (a JavaScript variant)

2

Copyright	
  2013	
  Demandware,	
  Inc.	
  All	
  other	
  rights	
  reserved.
Agenda
•
•
•
•
•
•

November	
  7th,	
  2013

What is AngularJS?
Challenges & solutions
Terminology
Sample App I: Hello
Sample App II: Zwitschermaschine
Conclusion

3

Copyright	
  2013	
  Demandware,	
  Inc.	
  All	
  other	
  rights	
  reserved.
What is AngularJS?

•
•
•
•

Client-side JavaScript framework (i.e., runs in a browser)
“Superheroic JavaScript MVW Framework”
W = Whatever works for you
Model View Controller vs. Model View View-Model

•

Not a breakthrough, but a smart selection of best of
breed approaches

•
•

Started by Google in 2009
Released as 1.0 in 2012

November	
  7th,	
  2013

4

Copyright	
  2013	
  Demandware,	
  Inc.	
  All	
  other	
  rights	
  reserved.
Challenges & solutions

November	
  7th,	
  2013

5

Copyright	
  2013	
  Demandware,	
  Inc.	
  All	
  other	
  rights	
  reserved.
Challenges & solutions
Boilerplate code

Single page applications

Rich user interface
Development speed

Forms

Maintainability

Browser incompatibilities
Testability

November	
  7th,	
  2013

5

Copyright	
  2013	
  Demandware,	
  Inc.	
  All	
  other	
  rights	
  reserved.
Challenges & solutions
Dependency injection

REST

Boilerplate code

Single page applications
Partials/routing

Templates

Rich user interface
Development speed
MVC
Maintainability

Directives
Forms
(Bidirectional) data binding

Browser incompatibilities

Unit tests
Testability

(Abstraction) services
End to end tests

November	
  7th,	
  2013

5

Copyright	
  2013	
  Demandware,	
  Inc.	
  All	
  other	
  rights	
  reserved.
Terminology
Module
• Unit for the specification of dependencies (high-level)

Directive
• (UI) Control (defined by yourself or third parties)

View
• HTML page with special tags (“directives”)

Controller
• (Client-side) backend to a view

Scope
• View Model, shared object between view and controller
• Hierarchical

Service
• other application components (defined by AngularJS, yourself or third parties), e.g.,
for communicating with backend services or for using browser functionality in a
browser independent way
November	
  7th,	
  2013

6

Copyright	
  2013	
  Demandware,	
  Inc.	
  All	
  other	
  rights	
  reserved.
Sample App I: Hello
Minimum Angular Application
• index.html
• app.js

Demo

November	
  7th,	
  2013

7

Copyright	
  2013	
  Demandware,	
  Inc.	
  All	
  other	
  rights	
  reserved.
Summary
Bootstrapping Angular
• Declaring the DOM part to be processed: ng-app=”<module-name>”
• Include Angular: <script src="angular.js"></script>
• Include Angular module: <script src=”app.js”></script>

Client-side templates
• Parts of DOM are bound to values in the scope
• Standard Syntax: {{expression}}

Bidirectional data-binding
•
•
•
•

November	
  7th,	
  2013

Button: ng-click
Input: ng-model
Title: ng-bind-template
Image: ng-href

8

Copyright	
  2013	
  Demandware,	
  Inc.	
  All	
  other	
  rights	
  reserved.
Summary
Naming of attributes/elements defined by/with AngularJS
•
•
•
•

November	
  7th,	
  2013

ng-model
ng:model (XML)
data-ng-model (HTML 5)
x-ng-model (XHTML)

9

Copyright	
  2013	
  Demandware,	
  Inc.	
  All	
  other	
  rights	
  reserved.
Sample App II: Zwitschermaschine

November	
  7th,	
  2013

10

Copyright	
  2013	
  Demandware,	
  Inc.	
  All	
  other	
  rights	
  reserved.
Step 1: Partials/Routing
Demo

November	
  7th,	
  2013

11

Copyright	
  2013	
  Demandware,	
  Inc.	
  All	
  other	
  rights	
  reserved.
Summary
Dependency Injection
• Controller is registered at module along with its dependencies
• Syntax:
controller('Controller',
['dep1', 'dep2', ...,
function(dep1, dep2, ...) { ... }
])
• Array of size n+1 containing
- n Strings defining dependencies (by name)
- a function with n parameters

Partials/routing
•
•
•
•

November	
  7th,	
  2013

Single page application: constant frame with variable content
Variable content selected via URL
Insertion point for partial pages: ng-view
Configuration of content: $routeProvider

12

Copyright	
  2013	
  Demandware,	
  Inc.	
  All	
  other	
  rights	
  reserved.
Step 2: Adding a Form
Demo

November	
  7th,	
  2013

13

Copyright	
  2013	
  Demandware,	
  Inc.	
  All	
  other	
  rights	
  reserved.
Summary
Controller
• Defines scope for associated form
• Syntax: ng-controller

Bidirectional data binding

• Retrieval a value first from controller’s scope, than from $rootScope
• Setting a value to the controller’s scope

November	
  7th,	
  2013

14

Copyright	
  2013	
  Demandware,	
  Inc.	
  All	
  other	
  rights	
  reserved.
Step 3: REST communication
Demo

November	
  7th,	
  2013

15

Copyright	
  2013	
  Demandware,	
  Inc.	
  All	
  other	
  rights	
  reserved.
Summary
ngResource
• Separate AngularJS module
• Powerful abstraction of REST communication

Client-side templates
• Loops: ng-repeat
• Filters: {{ expression | filter }}
• Forcing an update of the view: $scope.$apply

November	
  7th,	
  2013

16

Copyright	
  2013	
  Demandware,	
  Inc.	
  All	
  other	
  rights	
  reserved.
Step 4: Directives
Demo

November	
  7th,	
  2013

17

Copyright	
  2013	
  Demandware,	
  Inc.	
  All	
  other	
  rights	
  reserved.
Summary
Directives
• Registration at module
• Usage as element, attribute, class or comment: restrict: ’EAMC’
- Element (E) <custom-ctrl title=”Title”/>
- Attribute (A) <div custom-ctrl=”Title”/>
<div class=”custom-ctrl:Title”/>
- Class (C)
- Comment (M) <!-- directive: custom-ctrl Title -->
• Isolated scope: scope {attributeName: ’@|=|&’}
- Fosters reusability
- Value (@) Pass attribute value as string literal
- Bound (=) Establish data binding between directive and parent scope
- Function (&) Pass a function in the parent scope

November	
  7th,	
  2013

18

Copyright	
  2013	
  Demandware,	
  Inc.	
  All	
  other	
  rights	
  reserved.
Summary
Directives
• Defining the content
- Template: template: { ... } / templateUrl: { ... }
Can replace the directive: replace: true
Can add to the directive’s parent element: replace: false
Can include the directive’s content:
transclude: true + ng:transclude
- Pair of compile/link functions
compile function is invoked once on the directive
link function is invoked once per use of the directive
• Communication between directives
• Priority definition to influence evaluation order
• Existing directives: charting, grids etc.

November	
  7th,	
  2013

19

Copyright	
  2013	
  Demandware,	
  Inc.	
  All	
  other	
  rights	
  reserved.
Step 5: Testing
Demo

November	
  7th,	
  2013

20

Copyright	
  2013	
  Demandware,	
  Inc.	
  All	
  other	
  rights	
  reserved.
Summary
Unit tests
• Jasmine syntax to specify tests: describe/it
• Karma for test execution
- Browser configurable (Chrome, Firefox, Safari, IE, PhantomJS)
- auto-watch possible

End-to-end tests

• Capabilities to mock HTTP servers
• UI introspection using jquery selectors
• Karma for test execution

November	
  7th,	
  2013

21

Copyright	
  2013	
  Demandware,	
  Inc.	
  All	
  other	
  rights	
  reserved.
Conclusion
Logic at the right place
• JSP “This shouldn’t be done here!”
• Angular “This is the right place!”

Well-thought aggregation of established techniques
• Dependency injection as new mean in the JavaScript technological space
• Adaption of known best-of-breed approaches

Under development
• Sometimes libraries change (too) fast

November	
  7th,	
  2013

22

Copyright	
  2013	
  Demandware,	
  Inc.	
  All	
  other	
  rights	
  reserved.
Thank you!

November	
  7th,	
  2013

23

Copyright	
  2013	
  Demandware,	
  Inc.	
  All	
  other	
  rights	
  reserved.
Predefined Services
$rootScope

Access to the parent of all scopes (“root scope”)

$location

Access to URL in address bar

$routeProvider

Definition of URL/partials mapping

$compile

Compiles HTML with angular directives

$http

Service for low-level HTTP communication

$resource

High-level REST communication

$log

Abstraction of console.log

...

November	
  7th,	
  2013

24

Copyright	
  2013	
  Demandware,	
  Inc.	
  All	
  other	
  rights	
  reserved.
Module API
config(configFn)

Configuration function to be executed during module loading

constant(name, object)

Registration of an application-wide constant

controller(name, ctor)

Registration of a controller

directive(name, ctor)

Registration of a directive

filter(name, ctor)

Registration of a filter

run(initFn)

Run function to be executed directly before the application
gets accessible by the user

service(name, ctor)

Registration of a constructor method that new is invoked on to
retrieve an object

factory(name, factory)

Registration of a function that is responsible for creating an
object

provider(name, factory)

Combination of factory and service, only providers are
accessible in config invocations

November	
  7th,	
  2013

25

Copyright	
  2013	
  Demandware,	
  Inc.	
  All	
  other	
  rights	
  reserved.
Configuring couchdb
CouchDB & Futon
• Used version: 1.3.1

default.ini

• Enable CORS
[httpd]
enable_cors = true
[cors]
origins = *

November	
  7th,	
  2013

26

Copyright	
  2013	
  Demandware,	
  Inc.	
  All	
  other	
  rights	
  reserved.

More Related Content

What's hot

Backbone JS for mobile apps
Backbone JS for mobile appsBackbone JS for mobile apps
Backbone JS for mobile appsIvano Malavolta
 
Modern development paradigms
Modern development paradigmsModern development paradigms
Modern development paradigmsIvano Malavolta
 
AEM Sightly Template Language
AEM Sightly Template LanguageAEM Sightly Template Language
AEM Sightly Template LanguageGabriel Walt
 
Sling Models Using Sightly and JSP by Deepak Khetawat
Sling Models Using Sightly and JSP by Deepak KhetawatSling Models Using Sightly and JSP by Deepak Khetawat
Sling Models Using Sightly and JSP by Deepak KhetawatAEM HUB
 
Web Components v1
Web Components v1Web Components v1
Web Components v1Mike Wilcox
 
Apache Sling Generic Validation Framework
Apache Sling Generic Validation FrameworkApache Sling Generic Validation Framework
Apache Sling Generic Validation FrameworkRadu Cotescu
 
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
 
AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)Gary Arora
 
HTL(Sightly) - All you need to know
HTL(Sightly) - All you need to knowHTL(Sightly) - All you need to know
HTL(Sightly) - All you need to knowPrabhdeep Singh
 
The Modern Java Web Developer - JavaOne 2013
The Modern Java Web Developer - JavaOne 2013The Modern Java Web Developer - JavaOne 2013
The Modern Java Web Developer - JavaOne 2013Matt Raible
 
AEM Sightly Deep Dive
AEM Sightly Deep DiveAEM Sightly Deep Dive
AEM Sightly Deep DiveGabriel Walt
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React NativeRami Sayar
 
Angular or Backbone: Go Mobile!
Angular or Backbone: Go Mobile!Angular or Backbone: Go Mobile!
Angular or Backbone: Go Mobile!Doris Chen
 

What's hot (20)

slingmodels
slingmodelsslingmodels
slingmodels
 
Backbone JS for mobile apps
Backbone JS for mobile appsBackbone JS for mobile apps
Backbone JS for mobile apps
 
Modern development paradigms
Modern development paradigmsModern development paradigms
Modern development paradigms
 
AEM Sightly Template Language
AEM Sightly Template LanguageAEM Sightly Template Language
AEM Sightly Template Language
 
AngularJS Basics
AngularJS BasicsAngularJS Basics
AngularJS Basics
 
Sling Models Using Sightly and JSP by Deepak Khetawat
Sling Models Using Sightly and JSP by Deepak KhetawatSling Models Using Sightly and JSP by Deepak Khetawat
Sling Models Using Sightly and JSP by Deepak Khetawat
 
Web Components v1
Web Components v1Web Components v1
Web Components v1
 
[2015/2016] Backbone JS
[2015/2016] Backbone JS[2015/2016] Backbone JS
[2015/2016] Backbone JS
 
Apache Sling Generic Validation Framework
Apache Sling Generic Validation FrameworkApache Sling Generic Validation Framework
Apache Sling Generic Validation Framework
 
EVOLVE'14 | Enhance | Gabriel Walt | Sightly Component Development
EVOLVE'14 | Enhance | Gabriel Walt | Sightly Component DevelopmentEVOLVE'14 | Enhance | Gabriel Walt | Sightly Component Development
EVOLVE'14 | Enhance | Gabriel Walt | Sightly Component Development
 
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
 
AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)
 
Handlebars & Require JS
Handlebars  & Require JSHandlebars  & Require JS
Handlebars & Require JS
 
HTL(Sightly) - All you need to know
HTL(Sightly) - All you need to knowHTL(Sightly) - All you need to know
HTL(Sightly) - All you need to know
 
Wt unit 5 client &amp; server side framework
Wt unit 5 client &amp; server side frameworkWt unit 5 client &amp; server side framework
Wt unit 5 client &amp; server side framework
 
The Modern Java Web Developer - JavaOne 2013
The Modern Java Web Developer - JavaOne 2013The Modern Java Web Developer - JavaOne 2013
The Modern Java Web Developer - JavaOne 2013
 
AEM Sightly Deep Dive
AEM Sightly Deep DiveAEM Sightly Deep Dive
AEM Sightly Deep Dive
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React Native
 
Angular or Backbone: Go Mobile!
Angular or Backbone: Go Mobile!Angular or Backbone: Go Mobile!
Angular or Backbone: Go Mobile!
 
Angular js
Angular jsAngular js
Angular js
 

Similar to An Introduction to AngularJS

The Basics Angular JS
The Basics Angular JS The Basics Angular JS
The Basics Angular JS OrisysIndia
 
TallyJS #1 - Intro to AngularJS
TallyJS #1 - Intro to AngularJSTallyJS #1 - Intro to AngularJS
TallyJS #1 - Intro to AngularJSAndrew Hart
 
When to use and when not to use AngularJS - Liju Pillai, www.perfomatix.com
When to use and when not to use AngularJS - Liju Pillai, www.perfomatix.comWhen to use and when not to use AngularJS - Liju Pillai, www.perfomatix.com
When to use and when not to use AngularJS - Liju Pillai, www.perfomatix.comPerfomatix Solutions
 
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
 
AngularJS in Production (CTO Forum)
AngularJS in Production (CTO Forum)AngularJS in Production (CTO Forum)
AngularJS in Production (CTO Forum)Alex Ross
 
Angular patterns
Angular patternsAngular patterns
Angular patternsPremkumar M
 
Exploring AngularJS - Liju Pillai
Exploring AngularJS - Liju PillaiExploring AngularJS - Liju Pillai
Exploring AngularJS - Liju PillaiLiju Pillai
 
Step by Step - AngularJS
Step by Step - AngularJSStep by Step - AngularJS
Step by Step - AngularJSInfragistics
 
Angularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetupAngularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetupGoutam Dey
 
Learning AngularJS - Complete coverage of AngularJS features and concepts
Learning AngularJS  - Complete coverage of AngularJS features and conceptsLearning AngularJS  - Complete coverage of AngularJS features and concepts
Learning AngularJS - Complete coverage of AngularJS features and conceptsSuresh Patidar
 
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
 
intoduction to Grails Framework
intoduction to Grails Frameworkintoduction to Grails Framework
intoduction to Grails FrameworkHarshdeep Kaur
 
Coffee@DBG - Exploring Angular JS
Coffee@DBG - Exploring Angular JSCoffee@DBG - Exploring Angular JS
Coffee@DBG - Exploring Angular JSDeepu S Nath
 
Integrating AngularJS into the Campus CMS
Integrating AngularJS into the Campus CMSIntegrating AngularJS into the Campus CMS
Integrating AngularJS into the Campus CMSTom Borger
 
Drupal & AngularJS - DrupalCamp Spain 2014
Drupal & AngularJS - DrupalCamp Spain 2014Drupal & AngularJS - DrupalCamp Spain 2014
Drupal & AngularJS - DrupalCamp Spain 2014Juampy NR
 

Similar to An Introduction to AngularJS (20)

The Basics Angular JS
The Basics Angular JS The Basics Angular JS
The Basics Angular JS
 
TallyJS #1 - Intro to AngularJS
TallyJS #1 - Intro to AngularJSTallyJS #1 - Intro to AngularJS
TallyJS #1 - Intro to AngularJS
 
Angular js
Angular jsAngular js
Angular js
 
When to use and when not to use AngularJS - Liju Pillai, www.perfomatix.com
When to use and when not to use AngularJS - Liju Pillai, www.perfomatix.comWhen to use and when not to use AngularJS - Liju Pillai, www.perfomatix.com
When to use and when not to use AngularJS - Liju Pillai, www.perfomatix.com
 
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
 
AngularJS in Production (CTO Forum)
AngularJS in Production (CTO Forum)AngularJS in Production (CTO Forum)
AngularJS in Production (CTO Forum)
 
Angular js
Angular jsAngular js
Angular js
 
Angular patterns
Angular patternsAngular patterns
Angular patterns
 
Exploring AngularJS - Liju Pillai
Exploring AngularJS - Liju PillaiExploring AngularJS - Liju Pillai
Exploring AngularJS - Liju Pillai
 
Step by Step - AngularJS
Step by Step - AngularJSStep by Step - AngularJS
Step by Step - AngularJS
 
Angularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetupAngularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetup
 
Learning AngularJS - Complete coverage of AngularJS features and concepts
Learning AngularJS  - Complete coverage of AngularJS features and conceptsLearning AngularJS  - Complete coverage of AngularJS features and concepts
Learning AngularJS - Complete coverage of AngularJS features and concepts
 
Angular js workshop
Angular js workshopAngular js workshop
Angular js workshop
 
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
 
intoduction to Grails Framework
intoduction to Grails Frameworkintoduction to Grails Framework
intoduction to Grails Framework
 
Coffee@DBG - Exploring Angular JS
Coffee@DBG - Exploring Angular JSCoffee@DBG - Exploring Angular JS
Coffee@DBG - Exploring Angular JS
 
Integrating AngularJS into the Campus CMS
Integrating AngularJS into the Campus CMSIntegrating AngularJS into the Campus CMS
Integrating AngularJS into the Campus CMS
 
Introduction to AngularJs
Introduction to AngularJsIntroduction to AngularJs
Introduction to AngularJs
 
Drupal & AngularJS - DrupalCamp Spain 2014
Drupal & AngularJS - DrupalCamp Spain 2014Drupal & AngularJS - DrupalCamp Spain 2014
Drupal & AngularJS - DrupalCamp Spain 2014
 
Dive into AngularJS and directives
Dive into AngularJS and directivesDive into AngularJS and directives
Dive into AngularJS and directives
 

More from Falk Hartmann

Risikomanagement in der Softwareentwicklung
Risikomanagement in der SoftwareentwicklungRisikomanagement in der Softwareentwicklung
Risikomanagement in der SoftwareentwicklungFalk Hartmann
 
Risiko Management in der Softwareentwicklung
Risiko Management in der SoftwareentwicklungRisiko Management in der Softwareentwicklung
Risiko Management in der SoftwareentwicklungFalk Hartmann
 
An Architecture for an XML-Template Engine enabling Safe Authoring
An Architecture for an XML-Template Engine enabling Safe AuthoringAn Architecture for an XML-Template Engine enabling Safe Authoring
An Architecture for an XML-Template Engine enabling Safe AuthoringFalk Hartmann
 
A Distributed Staged Architecture for Multimodal Applications
A Distributed Staged Architecture for Multimodal ApplicationsA Distributed Staged Architecture for Multimodal Applications
A Distributed Staged Architecture for Multimodal ApplicationsFalk Hartmann
 
Drahtwanderung: Wir machen den NeXTen Schritt
Drahtwanderung: Wir machen den NeXTen SchrittDrahtwanderung: Wir machen den NeXTen Schritt
Drahtwanderung: Wir machen den NeXTen SchrittFalk Hartmann
 
Technologieraum übergreifende Programmierung
Technologieraum übergreifende ProgrammierungTechnologieraum übergreifende Programmierung
Technologieraum übergreifende ProgrammierungFalk Hartmann
 
Sichere templategestützte Verarbeitung von XML-Dokumenten
Sichere templategestützte Verarbeitung von XML-DokumentenSichere templategestützte Verarbeitung von XML-Dokumenten
Sichere templategestützte Verarbeitung von XML-DokumentenFalk Hartmann
 
Protocol Engineering: Beschreibung und Entwicklung von Kommunikationsprotokollen
Protocol Engineering: Beschreibung und Entwicklung von KommunikationsprotokollenProtocol Engineering: Beschreibung und Entwicklung von Kommunikationsprotokollen
Protocol Engineering: Beschreibung und Entwicklung von KommunikationsprotokollenFalk Hartmann
 

More from Falk Hartmann (9)

Risikomanagement in der Softwareentwicklung
Risikomanagement in der SoftwareentwicklungRisikomanagement in der Softwareentwicklung
Risikomanagement in der Softwareentwicklung
 
Risiko Management in der Softwareentwicklung
Risiko Management in der SoftwareentwicklungRisiko Management in der Softwareentwicklung
Risiko Management in der Softwareentwicklung
 
D3ML Session
D3ML SessionD3ML Session
D3ML Session
 
An Architecture for an XML-Template Engine enabling Safe Authoring
An Architecture for an XML-Template Engine enabling Safe AuthoringAn Architecture for an XML-Template Engine enabling Safe Authoring
An Architecture for an XML-Template Engine enabling Safe Authoring
 
A Distributed Staged Architecture for Multimodal Applications
A Distributed Staged Architecture for Multimodal ApplicationsA Distributed Staged Architecture for Multimodal Applications
A Distributed Staged Architecture for Multimodal Applications
 
Drahtwanderung: Wir machen den NeXTen Schritt
Drahtwanderung: Wir machen den NeXTen SchrittDrahtwanderung: Wir machen den NeXTen Schritt
Drahtwanderung: Wir machen den NeXTen Schritt
 
Technologieraum übergreifende Programmierung
Technologieraum übergreifende ProgrammierungTechnologieraum übergreifende Programmierung
Technologieraum übergreifende Programmierung
 
Sichere templategestützte Verarbeitung von XML-Dokumenten
Sichere templategestützte Verarbeitung von XML-DokumentenSichere templategestützte Verarbeitung von XML-Dokumenten
Sichere templategestützte Verarbeitung von XML-Dokumenten
 
Protocol Engineering: Beschreibung und Entwicklung von Kommunikationsprotokollen
Protocol Engineering: Beschreibung und Entwicklung von KommunikationsprotokollenProtocol Engineering: Beschreibung und Entwicklung von Kommunikationsprotokollen
Protocol Engineering: Beschreibung und Entwicklung von Kommunikationsprotokollen
 

Recently uploaded

Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessWSO2
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...Karmanjay Verma
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFMichael Gough
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sectoritnewsafrica
 
Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentMahmoud Rabie
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Nikki Chapple
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...BookNet Canada
 

Recently uploaded (20)

Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with Platformless
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDF
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
 
Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career Development
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
 

An Introduction to AngularJS

  • 1. An Introduction to AngularJS Falk Hartmann November  7th,  2013 2/12/13 1 Copyright  2013  Demandware,  Inc.  Anc.  ther  ther  rights  reserved.   Copyright  2013  Demandware,  I ll  o All  o rights  reserved.
  • 2. My Main Areas of Expertise • • • • • Java Markup Languages Identity and Access Management OSGi ActionScript/MXML Demandware • • • • November  7th,  2013 Develops and operates an enterprise-class cloud commerce platform since 2004 160 retail brands with more than 665 sites world-wide Offices in Jena, Burlington (MA), Munich, Paris, London Technologies - Java, JEE, Spring - Oracle, MongoDB, Redis, ElasticSearch - Demandware Script (a JavaScript variant) 2 Copyright  2013  Demandware,  Inc.  All  other  rights  reserved.
  • 3. Agenda • • • • • • November  7th,  2013 What is AngularJS? Challenges & solutions Terminology Sample App I: Hello Sample App II: Zwitschermaschine Conclusion 3 Copyright  2013  Demandware,  Inc.  All  other  rights  reserved.
  • 4. What is AngularJS? • • • • Client-side JavaScript framework (i.e., runs in a browser) “Superheroic JavaScript MVW Framework” W = Whatever works for you Model View Controller vs. Model View View-Model • Not a breakthrough, but a smart selection of best of breed approaches • • Started by Google in 2009 Released as 1.0 in 2012 November  7th,  2013 4 Copyright  2013  Demandware,  Inc.  All  other  rights  reserved.
  • 5. Challenges & solutions November  7th,  2013 5 Copyright  2013  Demandware,  Inc.  All  other  rights  reserved.
  • 6. Challenges & solutions Boilerplate code Single page applications Rich user interface Development speed Forms Maintainability Browser incompatibilities Testability November  7th,  2013 5 Copyright  2013  Demandware,  Inc.  All  other  rights  reserved.
  • 7. Challenges & solutions Dependency injection REST Boilerplate code Single page applications Partials/routing Templates Rich user interface Development speed MVC Maintainability Directives Forms (Bidirectional) data binding Browser incompatibilities Unit tests Testability (Abstraction) services End to end tests November  7th,  2013 5 Copyright  2013  Demandware,  Inc.  All  other  rights  reserved.
  • 8. Terminology Module • Unit for the specification of dependencies (high-level) Directive • (UI) Control (defined by yourself or third parties) View • HTML page with special tags (“directives”) Controller • (Client-side) backend to a view Scope • View Model, shared object between view and controller • Hierarchical Service • other application components (defined by AngularJS, yourself or third parties), e.g., for communicating with backend services or for using browser functionality in a browser independent way November  7th,  2013 6 Copyright  2013  Demandware,  Inc.  All  other  rights  reserved.
  • 9. Sample App I: Hello Minimum Angular Application • index.html • app.js Demo November  7th,  2013 7 Copyright  2013  Demandware,  Inc.  All  other  rights  reserved.
  • 10. Summary Bootstrapping Angular • Declaring the DOM part to be processed: ng-app=”<module-name>” • Include Angular: <script src="angular.js"></script> • Include Angular module: <script src=”app.js”></script> Client-side templates • Parts of DOM are bound to values in the scope • Standard Syntax: {{expression}} Bidirectional data-binding • • • • November  7th,  2013 Button: ng-click Input: ng-model Title: ng-bind-template Image: ng-href 8 Copyright  2013  Demandware,  Inc.  All  other  rights  reserved.
  • 11. Summary Naming of attributes/elements defined by/with AngularJS • • • • November  7th,  2013 ng-model ng:model (XML) data-ng-model (HTML 5) x-ng-model (XHTML) 9 Copyright  2013  Demandware,  Inc.  All  other  rights  reserved.
  • 12. Sample App II: Zwitschermaschine November  7th,  2013 10 Copyright  2013  Demandware,  Inc.  All  other  rights  reserved.
  • 13. Step 1: Partials/Routing Demo November  7th,  2013 11 Copyright  2013  Demandware,  Inc.  All  other  rights  reserved.
  • 14. Summary Dependency Injection • Controller is registered at module along with its dependencies • Syntax: controller('Controller', ['dep1', 'dep2', ..., function(dep1, dep2, ...) { ... } ]) • Array of size n+1 containing - n Strings defining dependencies (by name) - a function with n parameters Partials/routing • • • • November  7th,  2013 Single page application: constant frame with variable content Variable content selected via URL Insertion point for partial pages: ng-view Configuration of content: $routeProvider 12 Copyright  2013  Demandware,  Inc.  All  other  rights  reserved.
  • 15. Step 2: Adding a Form Demo November  7th,  2013 13 Copyright  2013  Demandware,  Inc.  All  other  rights  reserved.
  • 16. Summary Controller • Defines scope for associated form • Syntax: ng-controller Bidirectional data binding • Retrieval a value first from controller’s scope, than from $rootScope • Setting a value to the controller’s scope November  7th,  2013 14 Copyright  2013  Demandware,  Inc.  All  other  rights  reserved.
  • 17. Step 3: REST communication Demo November  7th,  2013 15 Copyright  2013  Demandware,  Inc.  All  other  rights  reserved.
  • 18. Summary ngResource • Separate AngularJS module • Powerful abstraction of REST communication Client-side templates • Loops: ng-repeat • Filters: {{ expression | filter }} • Forcing an update of the view: $scope.$apply November  7th,  2013 16 Copyright  2013  Demandware,  Inc.  All  other  rights  reserved.
  • 19. Step 4: Directives Demo November  7th,  2013 17 Copyright  2013  Demandware,  Inc.  All  other  rights  reserved.
  • 20. Summary Directives • Registration at module • Usage as element, attribute, class or comment: restrict: ’EAMC’ - Element (E) <custom-ctrl title=”Title”/> - Attribute (A) <div custom-ctrl=”Title”/> <div class=”custom-ctrl:Title”/> - Class (C) - Comment (M) <!-- directive: custom-ctrl Title --> • Isolated scope: scope {attributeName: ’@|=|&’} - Fosters reusability - Value (@) Pass attribute value as string literal - Bound (=) Establish data binding between directive and parent scope - Function (&) Pass a function in the parent scope November  7th,  2013 18 Copyright  2013  Demandware,  Inc.  All  other  rights  reserved.
  • 21. Summary Directives • Defining the content - Template: template: { ... } / templateUrl: { ... } Can replace the directive: replace: true Can add to the directive’s parent element: replace: false Can include the directive’s content: transclude: true + ng:transclude - Pair of compile/link functions compile function is invoked once on the directive link function is invoked once per use of the directive • Communication between directives • Priority definition to influence evaluation order • Existing directives: charting, grids etc. November  7th,  2013 19 Copyright  2013  Demandware,  Inc.  All  other  rights  reserved.
  • 22. Step 5: Testing Demo November  7th,  2013 20 Copyright  2013  Demandware,  Inc.  All  other  rights  reserved.
  • 23. Summary Unit tests • Jasmine syntax to specify tests: describe/it • Karma for test execution - Browser configurable (Chrome, Firefox, Safari, IE, PhantomJS) - auto-watch possible End-to-end tests • Capabilities to mock HTTP servers • UI introspection using jquery selectors • Karma for test execution November  7th,  2013 21 Copyright  2013  Demandware,  Inc.  All  other  rights  reserved.
  • 24. Conclusion Logic at the right place • JSP “This shouldn’t be done here!” • Angular “This is the right place!” Well-thought aggregation of established techniques • Dependency injection as new mean in the JavaScript technological space • Adaption of known best-of-breed approaches Under development • Sometimes libraries change (too) fast November  7th,  2013 22 Copyright  2013  Demandware,  Inc.  All  other  rights  reserved.
  • 25. Thank you! November  7th,  2013 23 Copyright  2013  Demandware,  Inc.  All  other  rights  reserved.
  • 26. Predefined Services $rootScope Access to the parent of all scopes (“root scope”) $location Access to URL in address bar $routeProvider Definition of URL/partials mapping $compile Compiles HTML with angular directives $http Service for low-level HTTP communication $resource High-level REST communication $log Abstraction of console.log ... November  7th,  2013 24 Copyright  2013  Demandware,  Inc.  All  other  rights  reserved.
  • 27. Module API config(configFn) Configuration function to be executed during module loading constant(name, object) Registration of an application-wide constant controller(name, ctor) Registration of a controller directive(name, ctor) Registration of a directive filter(name, ctor) Registration of a filter run(initFn) Run function to be executed directly before the application gets accessible by the user service(name, ctor) Registration of a constructor method that new is invoked on to retrieve an object factory(name, factory) Registration of a function that is responsible for creating an object provider(name, factory) Combination of factory and service, only providers are accessible in config invocations November  7th,  2013 25 Copyright  2013  Demandware,  Inc.  All  other  rights  reserved.
  • 28. Configuring couchdb CouchDB & Futon • Used version: 1.3.1 default.ini • Enable CORS [httpd] enable_cors = true [cors] origins = * November  7th,  2013 26 Copyright  2013  Demandware,  Inc.  All  other  rights  reserved.