SlideShare une entreprise Scribd logo
1  sur  42
1
Ganesh Kondal,
August 14, 2013
2
Today…
• Single Page Applications – What / Why / How ?
• Brief Introduction to Angular JS aspects.,
• Discuss Code – https://github.com/ganeshkondal/angularstore
• Not Today
• Unit testing JavaScript Client side applications – see karma
• Node Server backend used
• Web Application or JavaScript basics
• Comparison across JS MVW frameworks
“Feel free to interrupt and also to provide feedback”
3
Why SPA? Why now?
Technology Forecast &
the market is moving
towards it. Plus ‘not
just air’ – interesting
and its worth it
4
What is it?
“is a web application or web site that fits on a
single web page with the goal of providing a more
fluid user experience akin to a desktop application”
–Wikipedia
5
Single Page Application
• Web Apps not just web sites.
• Does not reload the page.
• Now driven with Javascript MVW frameworks
• Fluid UX Experience –
• Handles most of UI transactions in the client side.
• Loads majority of the code with a single page load
Timeline
…
6
Why SPA?
“Within the time taken to read a page, 35 million person minutes
will be spent waiting for traditional website pages to load “ –
Single Page Applications [Upcoming SPA book of O’Reilly]
• Traditional Websites are slow !!!
• Slow site – is costly to enterprise & drives the customer away
• Mostly done using MVC – page after page delivery
• Does not provide a fluid UX – HTML is not for dynamic views
• Another reason – static content gets served to dumb clients
• SPA is to deliver a desktop application experience to the user
• And SPA is not new
7
Why JS MVC?
• No Plugin / Less Bloat / One client language.
• jQuery is to manipulate DOM; for animation; hooking events
• Pain points – if jQuery is “all we have’
• State of the application is in DOM
• Logic and Presentation – “No separation of concerns”
• With more complicated flow – jQuery only code is
unmanageable / not modular
• Changes to features (UI or logic) in a large jQuery based
codebase ends in “Houston !!! We have a problem”
8
Are we the guinea pigs?
• YouTube PS3
• Airbnb
• Google
• Maps
• Calendar
• Mail
• …
No Way?
http://builtwith.angularjs.org/
9
SPA Frameworks
• Backbone JS
• Backbone. Marionette
• Angular JS – from Google
• Ember JS
• … many more
• See http://todomvc.com
10
Didn’t we say ‘Responsive’
“ web design approach aimed at crafting sites to provide an optimal viewing
experience—easy reading and navigation with a minimum of resizing, panning,
and scrolling—across a wide range of devices” - Wikipedia
• Grid positioning and element sizing in % and relative numbers
• Flexible images
• CSS3 media queries
• CSS3 RWD frameworks
• Responsivator
Enterprise Application
- SPA with JS MVC
Presentation Layer
Model View Controller
11
SPA Architecture
Enterprise Application
- Using traditional
MVC approach
Presentation Layer
Services Tier
Data Access Layer
Database
Config
Files
Ext
Systems
12
PART II
13
Why
• Angular is a MVVM / MVW framework; uses jQuery internally
• Some of the key features…
• Two-way data binding
• Dependency Injection
• HTML directives
• Reusable Services
• Custom Directives
• And a lot more…
• HTML 5 Routing
• HTML Templates
• Locale aware Filters
• Validation
• Nested form submission
• Expressions
+ Developed by / support from Google
14
Trivia
• Started by Google in 2009; Open Source
• Saw a 17000 to 1500 line reduction of code (92% reduction in code)
• 100% JavaScript & Client Side. Compatible with desktop & mobile.
• Not a plugin; nor a browser extension
• Compatible with HTTPS, Content Security Policy, XSRF protection.,
• Done via $http with server [xsrf-token; settingx-xsrf-token]
• Browsers – Safari, Chrome, IE8/9, Firefox, Opera;
– Mobile browsers (Android, Chrome Mobile, Safari)
• Size < 29Kb (compressed and minified)
• Uses jQuery or jQlite
15
Tool Sets
• Editor
• Sublime Text 2 Editor – tons of plugins
• $$ - Visual Studio or WebStorm IDE
• For Debugging –
• Chrome Browser
• Batarang [Angular JS plugin]
• Advanced REST Client OR Postman like Chrome / Firefox Plugin
• Firefox + firebug / jsFiddle …
• Library
• Bootstrap – CSS Framework
• Node Server (or Tomcat or IIS or Apache to host the pages)
16
Tool Sets contd.
• Angular Seed Project –
• https://github.com/angular/angular-seed
• Responsivator
• http://dfcb.github.io/Responsivator/?site=localhos
t%3A8082%2Fbooks
• To check multi-modality in one shot
• Responsinator – iphone like online
simulator
• http://www.responsinator.com/
17
Package Layout
UX code.
Reusable Services
Partial Views.
HTML Templates
SPA Entry Point
Controllers
(/controllers to be created)
Angular Seed – can provide the starting point
18
Sample # 1 – Hello World
• ng-app, ng-init;
• Go through directives, before Sample 2
19
Directives – HTML on steroids!!
• Directives teaches HTML new tricks [Dan Wahlin] by extending
HTML via attributes.
• ng-* - built in angular directives
• ng-app => Initializes the angular app.
• Built-in & Custom – directives
• Can be invoked as –
<span ng:bind="name"> ganesh
<span ng_bind="name"> ganesh
<span ng-bind="name"> ganesh
<span data-ng-bind="name"> ganesh
<span x-ng-bind="name"> ganesh `
20
Directives
• Event Directives
• ngChange
• ngClick
• ngMouseDown
• ngMouseOver
• ngMouseLeave
• …
• Other Directives
• ngApp
• ngBind
• ngHide
• ngShow
• ngForm
• …
<input type="checkbox" ng-change="handleChange()"
ng-model="property" />
<label ng-bind="book.title"/>
21
Sample 2 – Simple Data Binding
• Showcases view / model being tied.
• ng-bind
22
Model
• Any JS object can be the model
• No special class to extend
• Unlike Backbone.Model.extend )
• No special template code.
• Angular works directly on the
DOM; so any HTML subset can be
the template.
View
23
Two-way Data Binding
• View & Model bound to each other in a two-way binding
24
Sample 3 – Book Listing & Filter
• Controller sample
• $scope (DI), controller, filter,
• Modularity
25
Controller
• Code behind the view
• Tied via the $scope
• $scope separates view
and the controller
• Controller is pure JS.
• No rendering info.
• Can support many views as it is not tied to a view
• Controller and View get the variables via DI of angular
26
Filters & Expressions
• In-built filters are available
• to modify the output - $number
No fractions: {{ val | number : 0 } } <br/>
• to change the format $currency
• sort the returned data set orderBy: filter.name
• filter the data set, as the name says filter : filter.name
• For debugging
• Json filter is given in angular that prints in JSON style –
useful for debugging
<body> <pre>{{ {‘name’ : ‘value’} | json }} </pre> </body>
27
$scope
• Glue between controller & view
• Refers the application model
• Scopes are in a hierarchical manner
• Helps create ($broadcast) custom events
$watch
# ng-model
# ng-change
<div
ng-controller="Controller">
Name:
<input type="text" ng-
model=‚name">
<button ng-
click='sayHello()'>greet</but
ton>
<hr>
{{greeting}}
$scope directives
• Expressions’ execution context
• Provides API to observe, propagate
model changes outside – via $watch,
$apply
View
Linking
phase
28
Sample 4 – eStore
• Router, UI templates
• Services via Factory approach
• ngSanitize, ngSrc
https://github.com/ganeshkondal/angularstore
• Module Dependency
• HTML5 Routing
$scope
29
Routers
Routers
View ControllerConnects
- Router assigns the controller for a UI Template.
- $scope, $routerProvider - are depedency injected by Angular
HTML Templates
30
Routers contd.
31
Dependency Injection
• DI is pervasive – all over Angular.
• Controller gets hold of services it needs, auto-magically.
• View gets the necessary expression values.
• Each Angular application has $injector that injects the
dependent services (FYI only).
32
Pieces Together - Modules
Modules
Controllers
Directives Filters
Service
Factory
Provider
Config
Routes
View
Value
• Modules are the containers => think like ‘object containers’
• Always use ng-app=‚moduleName‛
$scope
33
Services
• Refers a common piece of code that you can use across
controllers. Not necessarily a REST or backend service call.
• Services are singleton apps
• Register a service – via .factory( serviceId, function(){..});
• OR via $provider interface.
• Always lazy initialized by Angular internally
34
Security – HTML Injection
• HTML injection from unknown source is the HOLE
• Default behavior = print the HTML content in variable as is
• ngSanitize provides methods
• ng-bind-html – enables to get the text portion
• ng-bind-html-unsafe – enables even allowing the styling
portion along with the HTML content honored as is.
@html
@controller
35
Next Session
• Integrate with Node JS or any REST service provider
• Organize / build code with Yeoman / Grunt (TODO list !!!)
• Test suite with Karma (ToDo list!!!)
• Custom Directives
36
Summary
- SPA – what is it & why we need it
- Angular JS - what is it & some trivia
- Few code samples
- Key take away from Angular
- Dependency Injection
- Directives
- Routers
37
Reference
- Angular JS – O’Reilly book
- http://angularjs.org
- www.youtube.com – Dan Wahlin’s video tutorials
38
Next Segment
- Integration with Node Backend
- Karma & Jasmine – TBD.,
39
Thank You
40
Appendix
41
Angular JS Runtime
• Hello Angular Sample !!!
• Angular script loaded
• Ng-app designates the
application boundary
• Ng-repeat Sample !!!
• Info on Controllers
42
SPA – FAQ
• What is dependency injected
• How it compares to backbone?
• How it compares to ember?
• What is the value model?
• Best Practices
• Upcoming; yet to settle in

Contenu connexe

Tendances

Introduction to Behavior Driven Development
Introduction to Behavior Driven Development Introduction to Behavior Driven Development
Introduction to Behavior Driven Development Robin O'Brien
 
The Economies of Scaling Software
The Economies of Scaling SoftwareThe Economies of Scaling Software
The Economies of Scaling SoftwareAbdelmonaim Remani
 
So What Do Cucumbers Have To Do With Testing
So What Do Cucumbers Have To Do With TestingSo What Do Cucumbers Have To Do With Testing
So What Do Cucumbers Have To Do With Testingsjmarsh
 
Delivery Pipeline for Windows Machines
Delivery Pipeline for Windows MachinesDelivery Pipeline for Windows Machines
Delivery Pipeline for Windows MachinesDmitry Buzdin
 
Как стать синьором
Как стать синьоромКак стать синьором
Как стать синьоромCOMAQA.BY
 
Metaprogramming JavaScript
Metaprogramming  JavaScriptMetaprogramming  JavaScript
Metaprogramming JavaScriptdanwrong
 
Current Testing Challenges Ireland
Current Testing Challenges IrelandCurrent Testing Challenges Ireland
Current Testing Challenges IrelandDavid O'Dowd
 
Do we need SOLID principles during software development?
Do we need SOLID principles during software development?Do we need SOLID principles during software development?
Do we need SOLID principles during software development?Anna Shymchenko
 
CBDW2014 - Behavior Driven Development with TestBox
CBDW2014 - Behavior Driven Development with TestBoxCBDW2014 - Behavior Driven Development with TestBox
CBDW2014 - Behavior Driven Development with TestBoxOrtus Solutions, Corp
 
Automate Your Data, Free Your Mind by Aaron Swerlein
Automate Your Data, Free Your Mind by Aaron SwerleinAutomate Your Data, Free Your Mind by Aaron Swerlein
Automate Your Data, Free Your Mind by Aaron SwerleinQA or the Highway
 
Coding Standard And Code Review
Coding Standard And Code ReviewCoding Standard And Code Review
Coding Standard And Code ReviewMilan Vukoje
 
Design For Testability
Design For TestabilityDesign For Testability
Design For TestabilityWill Iverson
 
Microsoft Fakes, Unit Testing the (almost) Untestable Code
Microsoft Fakes, Unit Testing the (almost) Untestable CodeMicrosoft Fakes, Unit Testing the (almost) Untestable Code
Microsoft Fakes, Unit Testing the (almost) Untestable CodeAleksandar Bozinovski
 
Foundations of Zend Framework
Foundations of Zend FrameworkFoundations of Zend Framework
Foundations of Zend FrameworkAdam Culp
 
The LAZY Developer's Guide to BDD (with Cucumber)
The LAZY Developer's Guide to BDD (with Cucumber)The LAZY Developer's Guide to BDD (with Cucumber)
The LAZY Developer's Guide to BDD (with Cucumber)Tze Yang Ng
 
Behavior Driven Development (BDD) and Agile Testing
Behavior Driven Development (BDD) and Agile TestingBehavior Driven Development (BDD) and Agile Testing
Behavior Driven Development (BDD) and Agile Testingdversaci
 

Tendances (20)

Introduction to Behavior Driven Development
Introduction to Behavior Driven Development Introduction to Behavior Driven Development
Introduction to Behavior Driven Development
 
The Economies of Scaling Software
The Economies of Scaling SoftwareThe Economies of Scaling Software
The Economies of Scaling Software
 
So What Do Cucumbers Have To Do With Testing
So What Do Cucumbers Have To Do With TestingSo What Do Cucumbers Have To Do With Testing
So What Do Cucumbers Have To Do With Testing
 
Delivery Pipeline for Windows Machines
Delivery Pipeline for Windows MachinesDelivery Pipeline for Windows Machines
Delivery Pipeline for Windows Machines
 
Как стать синьором
Как стать синьоромКак стать синьором
Как стать синьором
 
Workflow Yapceu2010
Workflow Yapceu2010Workflow Yapceu2010
Workflow Yapceu2010
 
Metaprogramming JavaScript
Metaprogramming  JavaScriptMetaprogramming  JavaScript
Metaprogramming JavaScript
 
Current Testing Challenges Ireland
Current Testing Challenges IrelandCurrent Testing Challenges Ireland
Current Testing Challenges Ireland
 
Do we need SOLID principles during software development?
Do we need SOLID principles during software development?Do we need SOLID principles during software development?
Do we need SOLID principles during software development?
 
CBDW2014 - Behavior Driven Development with TestBox
CBDW2014 - Behavior Driven Development with TestBoxCBDW2014 - Behavior Driven Development with TestBox
CBDW2014 - Behavior Driven Development with TestBox
 
Automate Your Data, Free Your Mind by Aaron Swerlein
Automate Your Data, Free Your Mind by Aaron SwerleinAutomate Your Data, Free Your Mind by Aaron Swerlein
Automate Your Data, Free Your Mind by Aaron Swerlein
 
Coding Standard And Code Review
Coding Standard And Code ReviewCoding Standard And Code Review
Coding Standard And Code Review
 
Design For Testability
Design For TestabilityDesign For Testability
Design For Testability
 
Microsoft Fakes, Unit Testing the (almost) Untestable Code
Microsoft Fakes, Unit Testing the (almost) Untestable CodeMicrosoft Fakes, Unit Testing the (almost) Untestable Code
Microsoft Fakes, Unit Testing the (almost) Untestable Code
 
Foundations of Zend Framework
Foundations of Zend FrameworkFoundations of Zend Framework
Foundations of Zend Framework
 
04 managing the database
04   managing the database04   managing the database
04 managing the database
 
ASP.NET security vulnerabilities
ASP.NET security vulnerabilitiesASP.NET security vulnerabilities
ASP.NET security vulnerabilities
 
Test Policy and Practices
Test Policy and PracticesTest Policy and Practices
Test Policy and Practices
 
The LAZY Developer's Guide to BDD (with Cucumber)
The LAZY Developer's Guide to BDD (with Cucumber)The LAZY Developer's Guide to BDD (with Cucumber)
The LAZY Developer's Guide to BDD (with Cucumber)
 
Behavior Driven Development (BDD) and Agile Testing
Behavior Driven Development (BDD) and Agile TestingBehavior Driven Development (BDD) and Agile Testing
Behavior Driven Development (BDD) and Agile Testing
 

En vedette

Better Living Through Storytelling
Better Living Through StorytellingBetter Living Through Storytelling
Better Living Through StorytellingAaron Aldrich
 
Presentacion de tecnologia
Presentacion de tecnologiaPresentacion de tecnologia
Presentacion de tecnologiakrishna_Mondaca
 
Olga Markina et Francois Laprade avec la Chine
Olga Markina et Francois Laprade avec la ChineOlga Markina et Francois Laprade avec la Chine
Olga Markina et Francois Laprade avec la ChineOlga Markina
 
The Political Economy of the Trans Pacific Partnership
The Political Economy of the Trans Pacific PartnershipThe Political Economy of the Trans Pacific Partnership
The Political Economy of the Trans Pacific PartnershipIra Kristina Lumban Tobing
 
UNCTAD OECD Sixteenth Report on G20 Investment Measures
UNCTAD OECD Sixteenth Report on G20 Investment MeasuresUNCTAD OECD Sixteenth Report on G20 Investment Measures
UNCTAD OECD Sixteenth Report on G20 Investment MeasuresIra Kristina Lumban Tobing
 
Símbolos patríos del perú
Símbolos patríos del perúSímbolos patríos del perú
Símbolos patríos del perúEiderzendamelania
 
20140818内刊投稿(刘胜)技术创新和专利申请.图文版v3.3
20140818内刊投稿(刘胜)技术创新和专利申请.图文版v3.320140818内刊投稿(刘胜)技术创新和专利申请.图文版v3.3
20140818内刊投稿(刘胜)技术创新和专利申请.图文版v3.3liu sheng
 
PCI DSS-based Security: Is This For Real? by Dr. Anton Chuvakin
PCI DSS-based Security: Is This For Real? by Dr. Anton ChuvakinPCI DSS-based Security: Is This For Real? by Dr. Anton Chuvakin
PCI DSS-based Security: Is This For Real? by Dr. Anton ChuvakinAnton Chuvakin
 
20150528联动技术大讲堂15(刘胜)业务系统上线标准指引
20150528联动技术大讲堂15(刘胜)业务系统上线标准指引20150528联动技术大讲堂15(刘胜)业务系统上线标准指引
20150528联动技术大讲堂15(刘胜)业务系统上线标准指引liu sheng
 
Good governance guidelines independence and transparency.
Good governance guidelines independence and transparency.Good governance guidelines independence and transparency.
Good governance guidelines independence and transparency.Ira Kristina Lumban Tobing
 
Canada - Ukraine Free Trade Agreement: A Primer for the Canadian Lawyer
Canada - Ukraine Free Trade Agreement: A Primer for the Canadian LawyerCanada - Ukraine Free Trade Agreement: A Primer for the Canadian Lawyer
Canada - Ukraine Free Trade Agreement: A Primer for the Canadian LawyerLexSage PC
 
Incorta Data Security
Incorta Data SecurityIncorta Data Security
Incorta Data SecurityDylan Wan
 
Si proyecto feria tec 7°
Si proyecto feria  tec 7° Si proyecto feria  tec 7°
Si proyecto feria tec 7° profesoraudp
 
7º blogger indicadores copia
7º  blogger indicadores copia7º  blogger indicadores copia
7º blogger indicadores copiaprofesoraudp
 
APEC: Cooperación Económica Asia Pacífico
APEC: Cooperación Económica Asia PacíficoAPEC: Cooperación Económica Asia Pacífico
APEC: Cooperación Económica Asia PacíficoMiguel Cruz Martínez
 
Presentación tpp
Presentación tppPresentación tpp
Presentación tppleo181516
 
Colour Blindness Ishihara Charts
Colour Blindness Ishihara ChartsColour Blindness Ishihara Charts
Colour Blindness Ishihara ChartsSomya Tyagi
 
coagulation system
coagulation systemcoagulation system
coagulation systemderosaMSKCC
 

En vedette (20)

Startup program details
Startup program detailsStartup program details
Startup program details
 
Better Living Through Storytelling
Better Living Through StorytellingBetter Living Through Storytelling
Better Living Through Storytelling
 
Presentacion de tecnologia
Presentacion de tecnologiaPresentacion de tecnologia
Presentacion de tecnologia
 
Olga Markina et Francois Laprade avec la Chine
Olga Markina et Francois Laprade avec la ChineOlga Markina et Francois Laprade avec la Chine
Olga Markina et Francois Laprade avec la Chine
 
The Political Economy of the Trans Pacific Partnership
The Political Economy of the Trans Pacific PartnershipThe Political Economy of the Trans Pacific Partnership
The Political Economy of the Trans Pacific Partnership
 
UNCTAD OECD Sixteenth Report on G20 Investment Measures
UNCTAD OECD Sixteenth Report on G20 Investment MeasuresUNCTAD OECD Sixteenth Report on G20 Investment Measures
UNCTAD OECD Sixteenth Report on G20 Investment Measures
 
Símbolos patríos del perú
Símbolos patríos del perúSímbolos patríos del perú
Símbolos patríos del perú
 
20140818内刊投稿(刘胜)技术创新和专利申请.图文版v3.3
20140818内刊投稿(刘胜)技术创新和专利申请.图文版v3.320140818内刊投稿(刘胜)技术创新和专利申请.图文版v3.3
20140818内刊投稿(刘胜)技术创新和专利申请.图文版v3.3
 
PCI DSS-based Security: Is This For Real? by Dr. Anton Chuvakin
PCI DSS-based Security: Is This For Real? by Dr. Anton ChuvakinPCI DSS-based Security: Is This For Real? by Dr. Anton Chuvakin
PCI DSS-based Security: Is This For Real? by Dr. Anton Chuvakin
 
20150528联动技术大讲堂15(刘胜)业务系统上线标准指引
20150528联动技术大讲堂15(刘胜)业务系统上线标准指引20150528联动技术大讲堂15(刘胜)业务系统上线标准指引
20150528联动技术大讲堂15(刘胜)业务系统上线标准指引
 
Good governance guidelines independence and transparency.
Good governance guidelines independence and transparency.Good governance guidelines independence and transparency.
Good governance guidelines independence and transparency.
 
Canada - Ukraine Free Trade Agreement: A Primer for the Canadian Lawyer
Canada - Ukraine Free Trade Agreement: A Primer for the Canadian LawyerCanada - Ukraine Free Trade Agreement: A Primer for the Canadian Lawyer
Canada - Ukraine Free Trade Agreement: A Primer for the Canadian Lawyer
 
Incorta Data Security
Incorta Data SecurityIncorta Data Security
Incorta Data Security
 
Si proyecto feria tec 7°
Si proyecto feria  tec 7° Si proyecto feria  tec 7°
Si proyecto feria tec 7°
 
7º blogger indicadores copia
7º  blogger indicadores copia7º  blogger indicadores copia
7º blogger indicadores copia
 
APEC: Cooperación Económica Asia Pacífico
APEC: Cooperación Económica Asia PacíficoAPEC: Cooperación Económica Asia Pacífico
APEC: Cooperación Económica Asia Pacífico
 
Presentación tpp
Presentación tppPresentación tpp
Presentación tpp
 
Colour Blindness Ishihara Charts
Colour Blindness Ishihara ChartsColour Blindness Ishihara Charts
Colour Blindness Ishihara Charts
 
coagulation system
coagulation systemcoagulation system
coagulation system
 
Dumping
DumpingDumping
Dumping
 

Similaire à Single Page Applications with AngularJS

AngularJS Beginners Workshop
AngularJS Beginners WorkshopAngularJS Beginners Workshop
AngularJS Beginners WorkshopSathish VJ
 
Angularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetupAngularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetupGoutam Dey
 
The future of web development write once, run everywhere with angular js an...
The future of web development   write once, run everywhere with angular js an...The future of web development   write once, run everywhere with angular js an...
The future of web development write once, run everywhere with angular js an...Mark Leusink
 
The future of web development write once, run everywhere with angular.js and ...
The future of web development write once, run everywhere with angular.js and ...The future of web development write once, run everywhere with angular.js and ...
The future of web development write once, run everywhere with angular.js and ...Mark Roden
 
Surrogate dependencies (in node js) v1.0
Surrogate dependencies  (in node js)  v1.0Surrogate dependencies  (in node js)  v1.0
Surrogate dependencies (in node js) v1.0Dinis Cruz
 
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 - 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
 
AngularJS 1.x - your first application (problems and solutions)
AngularJS 1.x - your first application (problems and solutions)AngularJS 1.x - your first application (problems and solutions)
AngularJS 1.x - your first application (problems and solutions)Igor Talevski
 
Exploring AngularJS - Liju Pillai
Exploring AngularJS - Liju PillaiExploring AngularJS - Liju Pillai
Exploring AngularJS - Liju PillaiLiju Pillai
 
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...Malin Weiss
 
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...Speedment, Inc.
 
Angular patterns
Angular patternsAngular patterns
Angular patternsPremkumar M
 
Valentine with Angular js - Introduction
Valentine with Angular js - IntroductionValentine with Angular js - Introduction
Valentine with Angular js - IntroductionSenthil Kumar
 
MEAN Stack Warm-up
MEAN Stack Warm-upMEAN Stack Warm-up
MEAN Stack Warm-upTroy Miles
 
Angular JS, A dive to concepts
Angular JS, A dive to conceptsAngular JS, A dive to concepts
Angular JS, A dive to conceptsAbhishek Sur
 
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2Jeremy Likness
 
Creating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJSCreating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJSGunnar Hillert
 

Similaire à Single Page Applications with AngularJS (20)

AngularJS Beginners Workshop
AngularJS Beginners WorkshopAngularJS Beginners Workshop
AngularJS Beginners Workshop
 
Angularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetupAngularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetup
 
The future of web development write once, run everywhere with angular js an...
The future of web development   write once, run everywhere with angular js an...The future of web development   write once, run everywhere with angular js an...
The future of web development write once, run everywhere with angular js an...
 
The future of web development write once, run everywhere with angular.js and ...
The future of web development write once, run everywhere with angular.js and ...The future of web development write once, run everywhere with angular.js and ...
The future of web development write once, run everywhere with angular.js and ...
 
Surrogate dependencies (in node js) v1.0
Surrogate dependencies  (in node js)  v1.0Surrogate dependencies  (in node js)  v1.0
Surrogate dependencies (in node js) v1.0
 
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
 
Angular js 1.3 basic tutorial
Angular js 1.3 basic tutorialAngular js 1.3 basic tutorial
Angular js 1.3 basic tutorial
 
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 
 
AngularJS 1.x - your first application (problems and solutions)
AngularJS 1.x - your first application (problems and solutions)AngularJS 1.x - your first application (problems and solutions)
AngularJS 1.x - your first application (problems and solutions)
 
Exploring AngularJS - Liju Pillai
Exploring AngularJS - Liju PillaiExploring AngularJS - Liju Pillai
Exploring AngularJS - Liju Pillai
 
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
 
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
 
Angular patterns
Angular patternsAngular patterns
Angular patterns
 
Valentine with Angular js - Introduction
Valentine with Angular js - IntroductionValentine with Angular js - Introduction
Valentine with Angular js - Introduction
 
Angular js
Angular jsAngular js
Angular js
 
Angular js for Beginnners
Angular js for BeginnnersAngular js for Beginnners
Angular js for Beginnners
 
MEAN Stack Warm-up
MEAN Stack Warm-upMEAN Stack Warm-up
MEAN Stack Warm-up
 
Angular JS, A dive to concepts
Angular JS, A dive to conceptsAngular JS, A dive to concepts
Angular JS, A dive to concepts
 
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2
 
Creating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJSCreating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJS
 

Dernier

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 

Dernier (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

Single Page Applications with AngularJS

  • 2. 2 Today… • Single Page Applications – What / Why / How ? • Brief Introduction to Angular JS aspects., • Discuss Code – https://github.com/ganeshkondal/angularstore • Not Today • Unit testing JavaScript Client side applications – see karma • Node Server backend used • Web Application or JavaScript basics • Comparison across JS MVW frameworks “Feel free to interrupt and also to provide feedback”
  • 3. 3 Why SPA? Why now? Technology Forecast & the market is moving towards it. Plus ‘not just air’ – interesting and its worth it
  • 4. 4 What is it? “is a web application or web site that fits on a single web page with the goal of providing a more fluid user experience akin to a desktop application” –Wikipedia
  • 5. 5 Single Page Application • Web Apps not just web sites. • Does not reload the page. • Now driven with Javascript MVW frameworks • Fluid UX Experience – • Handles most of UI transactions in the client side. • Loads majority of the code with a single page load Timeline …
  • 6. 6 Why SPA? “Within the time taken to read a page, 35 million person minutes will be spent waiting for traditional website pages to load “ – Single Page Applications [Upcoming SPA book of O’Reilly] • Traditional Websites are slow !!! • Slow site – is costly to enterprise & drives the customer away • Mostly done using MVC – page after page delivery • Does not provide a fluid UX – HTML is not for dynamic views • Another reason – static content gets served to dumb clients • SPA is to deliver a desktop application experience to the user • And SPA is not new
  • 7. 7 Why JS MVC? • No Plugin / Less Bloat / One client language. • jQuery is to manipulate DOM; for animation; hooking events • Pain points – if jQuery is “all we have’ • State of the application is in DOM • Logic and Presentation – “No separation of concerns” • With more complicated flow – jQuery only code is unmanageable / not modular • Changes to features (UI or logic) in a large jQuery based codebase ends in “Houston !!! We have a problem”
  • 8. 8 Are we the guinea pigs? • YouTube PS3 • Airbnb • Google • Maps • Calendar • Mail • … No Way? http://builtwith.angularjs.org/
  • 9. 9 SPA Frameworks • Backbone JS • Backbone. Marionette • Angular JS – from Google • Ember JS • … many more • See http://todomvc.com
  • 10. 10 Didn’t we say ‘Responsive’ “ web design approach aimed at crafting sites to provide an optimal viewing experience—easy reading and navigation with a minimum of resizing, panning, and scrolling—across a wide range of devices” - Wikipedia • Grid positioning and element sizing in % and relative numbers • Flexible images • CSS3 media queries • CSS3 RWD frameworks • Responsivator
  • 11. Enterprise Application - SPA with JS MVC Presentation Layer Model View Controller 11 SPA Architecture Enterprise Application - Using traditional MVC approach Presentation Layer Services Tier Data Access Layer Database Config Files Ext Systems
  • 13. 13 Why • Angular is a MVVM / MVW framework; uses jQuery internally • Some of the key features… • Two-way data binding • Dependency Injection • HTML directives • Reusable Services • Custom Directives • And a lot more… • HTML 5 Routing • HTML Templates • Locale aware Filters • Validation • Nested form submission • Expressions + Developed by / support from Google
  • 14. 14 Trivia • Started by Google in 2009; Open Source • Saw a 17000 to 1500 line reduction of code (92% reduction in code) • 100% JavaScript & Client Side. Compatible with desktop & mobile. • Not a plugin; nor a browser extension • Compatible with HTTPS, Content Security Policy, XSRF protection., • Done via $http with server [xsrf-token; settingx-xsrf-token] • Browsers – Safari, Chrome, IE8/9, Firefox, Opera; – Mobile browsers (Android, Chrome Mobile, Safari) • Size < 29Kb (compressed and minified) • Uses jQuery or jQlite
  • 15. 15 Tool Sets • Editor • Sublime Text 2 Editor – tons of plugins • $$ - Visual Studio or WebStorm IDE • For Debugging – • Chrome Browser • Batarang [Angular JS plugin] • Advanced REST Client OR Postman like Chrome / Firefox Plugin • Firefox + firebug / jsFiddle … • Library • Bootstrap – CSS Framework • Node Server (or Tomcat or IIS or Apache to host the pages)
  • 16. 16 Tool Sets contd. • Angular Seed Project – • https://github.com/angular/angular-seed • Responsivator • http://dfcb.github.io/Responsivator/?site=localhos t%3A8082%2Fbooks • To check multi-modality in one shot • Responsinator – iphone like online simulator • http://www.responsinator.com/
  • 17. 17 Package Layout UX code. Reusable Services Partial Views. HTML Templates SPA Entry Point Controllers (/controllers to be created) Angular Seed – can provide the starting point
  • 18. 18 Sample # 1 – Hello World • ng-app, ng-init; • Go through directives, before Sample 2
  • 19. 19 Directives – HTML on steroids!! • Directives teaches HTML new tricks [Dan Wahlin] by extending HTML via attributes. • ng-* - built in angular directives • ng-app => Initializes the angular app. • Built-in & Custom – directives • Can be invoked as – <span ng:bind="name"> ganesh <span ng_bind="name"> ganesh <span ng-bind="name"> ganesh <span data-ng-bind="name"> ganesh <span x-ng-bind="name"> ganesh `
  • 20. 20 Directives • Event Directives • ngChange • ngClick • ngMouseDown • ngMouseOver • ngMouseLeave • … • Other Directives • ngApp • ngBind • ngHide • ngShow • ngForm • … <input type="checkbox" ng-change="handleChange()" ng-model="property" /> <label ng-bind="book.title"/>
  • 21. 21 Sample 2 – Simple Data Binding • Showcases view / model being tied. • ng-bind
  • 22. 22 Model • Any JS object can be the model • No special class to extend • Unlike Backbone.Model.extend ) • No special template code. • Angular works directly on the DOM; so any HTML subset can be the template. View
  • 23. 23 Two-way Data Binding • View & Model bound to each other in a two-way binding
  • 24. 24 Sample 3 – Book Listing & Filter • Controller sample • $scope (DI), controller, filter, • Modularity
  • 25. 25 Controller • Code behind the view • Tied via the $scope • $scope separates view and the controller • Controller is pure JS. • No rendering info. • Can support many views as it is not tied to a view • Controller and View get the variables via DI of angular
  • 26. 26 Filters & Expressions • In-built filters are available • to modify the output - $number No fractions: {{ val | number : 0 } } <br/> • to change the format $currency • sort the returned data set orderBy: filter.name • filter the data set, as the name says filter : filter.name • For debugging • Json filter is given in angular that prints in JSON style – useful for debugging <body> <pre>{{ {‘name’ : ‘value’} | json }} </pre> </body>
  • 27. 27 $scope • Glue between controller & view • Refers the application model • Scopes are in a hierarchical manner • Helps create ($broadcast) custom events $watch # ng-model # ng-change <div ng-controller="Controller"> Name: <input type="text" ng- model=‚name"> <button ng- click='sayHello()'>greet</but ton> <hr> {{greeting}} $scope directives • Expressions’ execution context • Provides API to observe, propagate model changes outside – via $watch, $apply View Linking phase
  • 28. 28 Sample 4 – eStore • Router, UI templates • Services via Factory approach • ngSanitize, ngSrc https://github.com/ganeshkondal/angularstore • Module Dependency • HTML5 Routing
  • 29. $scope 29 Routers Routers View ControllerConnects - Router assigns the controller for a UI Template. - $scope, $routerProvider - are depedency injected by Angular HTML Templates
  • 31. 31 Dependency Injection • DI is pervasive – all over Angular. • Controller gets hold of services it needs, auto-magically. • View gets the necessary expression values. • Each Angular application has $injector that injects the dependent services (FYI only).
  • 32. 32 Pieces Together - Modules Modules Controllers Directives Filters Service Factory Provider Config Routes View Value • Modules are the containers => think like ‘object containers’ • Always use ng-app=‚moduleName‛ $scope
  • 33. 33 Services • Refers a common piece of code that you can use across controllers. Not necessarily a REST or backend service call. • Services are singleton apps • Register a service – via .factory( serviceId, function(){..}); • OR via $provider interface. • Always lazy initialized by Angular internally
  • 34. 34 Security – HTML Injection • HTML injection from unknown source is the HOLE • Default behavior = print the HTML content in variable as is • ngSanitize provides methods • ng-bind-html – enables to get the text portion • ng-bind-html-unsafe – enables even allowing the styling portion along with the HTML content honored as is. @html @controller
  • 35. 35 Next Session • Integrate with Node JS or any REST service provider • Organize / build code with Yeoman / Grunt (TODO list !!!) • Test suite with Karma (ToDo list!!!) • Custom Directives
  • 36. 36 Summary - SPA – what is it & why we need it - Angular JS - what is it & some trivia - Few code samples - Key take away from Angular - Dependency Injection - Directives - Routers
  • 37. 37 Reference - Angular JS – O’Reilly book - http://angularjs.org - www.youtube.com – Dan Wahlin’s video tutorials
  • 38. 38 Next Segment - Integration with Node Backend - Karma & Jasmine – TBD.,
  • 41. 41 Angular JS Runtime • Hello Angular Sample !!! • Angular script loaded • Ng-app designates the application boundary • Ng-repeat Sample !!! • Info on Controllers
  • 42. 42 SPA – FAQ • What is dependency injected • How it compares to backbone? • How it compares to ember? • What is the value model? • Best Practices • Upcoming; yet to settle in

Notes de l'éditeur

  1. Anyone asking about jQuery.extend?
  2. Anyone asking about jQuery.extend?
  3. Cross Site Request Forgery (XSRF) Protection XSRF is a technique by which an unauthorized site can gain your user&apos;s private data. Angular provides following mechanism to counter XSRF. When performing XHR requests, the $http service reads a token from a cookie called XSRF-TOKEN and sets it as the HTTP header X-XSRF-TOKEN. Since only JavaScript that runs on your domain could read the cookie, your server can be assured that the XHR came from JavaScript running on your domain.To take advantage of this, your server needs to set a token in a JavaScript readable session cookie called XSRF-TOKEN on first HTTP GET request. On subsequent non-GET requests the server can verify that the cookie matches X-XSRF-TOKEN HTTP header, and therefore be sure that only JavaScript running on your domain could have read the token. The token must be unique for each user and must be verifiable by the server (to prevent the JavaScript making up its own tokens). We recommend that the token is a digest of your site&apos;s authentication cookie with salt for added security.