SlideShare une entreprise Scribd logo
1  sur  56
Workingwith
Microsoft WebCamp 2014
May 20, 2014
2Aboutme
/56
André Vala
SharePoint Solutions Architect
Office & SharePoint Solutions Team Leader
andre.vala@create.pt
@atomicvee
http://blogit.create.pt/blogs/andrevala
http://www.linkedin.com/in/andrevala
3Agenda
 What is AngularJS?
 Main Concepts
 Tools
 BestPractices
 Wrappingup
/56
WhatisAngularJS?
“Angular is what HTML would have
been had it been designed for
applications.”
Miško Hevery
6WhatisAngularJS?
 SinglePageApplication(SPA)JavaScriptFramework
 Implementsclient-sideMVW pattern
 No directDOM manipulation, lesscode
 Wellorganizedand highly modular
 Focusedon testing
 Supports all majordesktopand mobilebrowsers
/56
Read More: https://plus.google.com/+AngularJS/posts/aZNVhj355G2
7History
 Createdby MiškoHevery
 Opensourcesince2009
 Supportedby Google
 Large and fast-growingcommunity
WHATISANGULARJS? /56
8SinglePageApplications
 Webapplicationscomposedof a singlepage
 Views(HTML Fragments)aredynamicallyloaded into the page
 Betteruserexperience(no reloads!)
 Calls to the serveraredone asynchronouslybehind the scenes
 Requireartificialhandling of browserhistory, navigation and
bookmarks
WHATISANGULARJS? /56
9Model-View-Whatever
 Somecallit MVC, othersMVVM...
 In the end, the namedoes not
matter. It handles separationof
concernsefectivelyseparating
presentationlogicfrombusiness
logicand presentationstate.
 Whatevermeans “whatever
worksfor you”.
WHATISANGULARJS? /56
Read More: https://plus.google.com/+AngularJS/posts/aZNVhj355G2
Model View
Whatever
10Trendingtopic
WHATISANGULARJS? /56
Source: Google Trends
11Learningcurve
WHATISANGULARJS? /56
MainConcepts
13Mainconcepts
 Templates
 Directives
 Expressions
 Data binding
 Scope
/56
 Controllers
 Modules
 Filters
 Services
 Routing
HelloWorld
DEMOMAINCONCEPTS
15Helloworldapplication
MAINCONCEPTS /56
<!doctype html>
<html ng-app>
<head>
<title>Demo 01 - Page 03</title>
<script src="libs/angular.min.js"></script>
</head>
<body>
<p>Name:<input id="textInput" type="text" ng-model="PersonName" /></p>
<p>Hello <span id="nameSpan">{{PersonName}}</span>!</p>
</body>
</html>
Directive
Directive
Expression
Template
16Templates
 HTML with additional markup
 Directives
 Expressions
 Filters
 Formcontrols
MAINCONCEPTS /56
Read More: https://docs.angularjs.org/guide/templates
17Directives
Markerson DOM elementsthat extendHTML vocabulary
 Attachbehaviourtothe DOMelement
 TransformtheDOM elementanditschildren
Directivescanmatch:
Elements <my-dir></my-dir>
Attributes <span my-dir="exp"></span>
Comments <!-- directive: my-dir exp -->
Classes <span class="my-dir: exp;"></span>
MAINCONCEPTS /56
Read More: https://docs.angularjs.org/guide/directive
18Namingformats
AngularJS HTML compilersupports multiplenamingformats
ng-bind Recommendedformat.
data-ng-bind Recommendedformattosupport HTMLvalidators.
ng_bind Legacypurposes. Avoidusingit.
ng:bind Legacypurposes. Avoidusing it.
x-ng-bind Legacypurposes. Avoidusing it.
MAINCONCEPTS/DIRECTIVES /56
Read More: https://docs.angularjs.org/guide/directive
19Built-indirectives
ngApp ngBind ngBindHtml ngBindTemplate ngBlur ngChange
ngChecked ngClass ngClassEven ngClassOdd ngClick ngCloak
ngController ngCopy ngCsp ngCut ngDblClick ngDisabled
ngFocus ngForm ngHide ngHref ngIf ngInclude ngInit
ngKeydown ngKeypress ngKeyup ngList ngModel ngModelOptions
ngMousedown ngMouseenter ngMouseleave ngMousemove
ngMouseover ngNonBindable ngOpen ngPaste ngPluralize
ngReadonly ngRepeat ngSelected ngShow ngSrc ngSrcset
ngStyle ngSubmit ngTransclude ngValue ngView
MAINCONCEPTS/DIRECTIVES /56
Read More: https://docs.angularjs.org/guide/directive
20Expressions
JavaScript-likecodesnippetsplacedinsidebindingssuchas
{{ expression }}
ValidAngularexpressions:
 {{ 1 + 2 }}
 {{ a + b }}
 {{ user.name }}
 {{ items[index] }}
Additionalnotesaboutexpressions:
 Controlflowstatementsarenotsupported(conditionals,loopsorexceptions)
 Youcanusefiltersinsideexpressionstoformatdata
MAINCONCEPTS /56
Read More: https://docs.angularjs.org/guide/expression
Expressions
DEMOMAINCONCEPTS
22Databinding
Automatic synchronizationof data betweenthe Modeland the View.
MAINCONCEPTS /56
Read More: https://docs.angularjs.org/guide/databinding
View
Template Model
One-time
merge
One-WayDataBinding
View
Template
Model
Continuous updates
Model is Single-Source-of-Truth
Compile
Changes to Model
updates View
Changes to View
updates Model
Two-WayDataBinding
Two-waydatabinding
DEMOMAINCONCEPTS
24Scope
 Objectthat refersto the applicationModel
 Valuesstored in variablesin the Scopebelong to the Model
 The glue betweenthe Controllerand the View
 Scopesarehierarchicaland followthe
DOM structureof the application
 EveryAngular applicationhas a root
scope($rootScope)mapped to the
elementlinked to ngApp directive
MAINCONCEPTS /56
Read More: https://docs.angularjs.org/guide/scope
25Controllers
 JavaScriptconstructorfunctions used to augmentthe Scope
 Newchild scopeis createdand
injectedas a constructor
parameter($scope)
MAINCONCEPTS /56
Read More: https://docs.angularjs.org/guide/controller
26Howtousecontrollers
Creatinga controllerinthe globalnamespace
function MyController($scope) {
...
}
Attachinga controllerto the DOM
<div ng-controller="MyController">
MAINCONCEPTS/CONTROLLERS /56
Read More: https://docs.angularjs.org/guide/controller
27Whentousecontrollers
 Usecontrollersto:
 Setup theinitialstateofthe$scope object
 Add behaviourtothe$scope object
 Do not use controllersto:
 ManipulateDOM(usedatabindinganddirectivesinstead)
 Formatinput (useformcontrolsinstead)
 Filteroutput (usefiltersinstead)
 Sharecodeorstateacrosscontrollers(useservicesinstead)
MAINCONCEPTS/CONTROLLERS /56
Read More: https://docs.angularjs.org/guide/controller
Usingcontrollers
DEMOMAINCONCEPTS
29Module
 Reusablecontainerfor differentfeaturesof anapp.
 Candependon othermodules.
Creatinga module
angular.module('myApp', []);
angular.module('myApp', ['myOtherModule']);
Referencinganapp’smainmodule
<html ng-app="myApp">
MAINCONCEPTS /56
Read More: https://docs.angularjs.org/guide/module
Usingmodules
DEMOMAINCONCEPTS
31Filters
 A filterformatsthevalueof anexpressionfor display to the user
 Can be used in view templates,controllers,servicesand directives
 You can createyour ownfilters (in a module)
 Built-in filters:
MAINCONCEPTS /56
Read More: https://docs.angularjs.org/guide/filter
Currency
Date
Filter
Json
LimitTo
Lowercase
Number
OrderBy
Uppercase
32Usingfiltersinviewtemplates
Singlefiltersyntax
{{ expression | filter }}
Example:{{ 12 | currency }} returns $12.00
Chainedfilterssyntax
{{ expression | filter1 | filter2 | ... }}
Filterwitharguments
{{ expression | filter:argument1:argument2... }}
Example:{{ 12 | number:2 }} returns 12.00
MAINCONCEPTS/FILTERS /56
Read More: https://docs.angularjs.org/guide/filter
33Usingfiltersincontrollers,servicesanddirectives
angular.module('FilterInControllerModule', []).
controller('FilterController', ['filterFilter', function(filterFilter) {
this.array = [
{name: 'Tobias'},
{name: 'Jeff'},
{name: 'Brian'},
{name: 'Igor'},
{name: 'James'},
{name: 'Brad'}
];
this.filteredArray = filterFilter(this.array, 'a');
}]);
MAINCONCEPTS/FILTERS /56
Read More: https://docs.angularjs.org/guide/filter
Inject filter in controller using
<filter name>Filter syntax
Receive filter function
as a parameter
Call filter with value to format
and additional parameters
34Creatingfilters
angular.module('MyFilterModule', []).
filter('myfilter', function() {
return function(input) {
...
return output;
};
});
MAINCONCEPTS/FILTERS /56
Read More: https://docs.angularjs.org/guide/filter
User the filter provider to
create a new filter in the
module
Name the filter
Return the filter function. The first
argument is the input value.
Additional arguments can be used.
Usingfilters
DEMOMAINCONCEPTS
36Services
 Reusablebusiness logiccomponentes,independentof views,wired
togetherusing dependencyinjection(DI).
 Singletonsgeneratedby a servicefactory.
 Angular only instantiatesa serviceif thereis a dependencyfor it.
 Built-in servicesstart with $.
Examples:$log, $http, $filter,$exceptionHandler
MAINCONCEPTS /56
Read More: https://docs.angularjs.org/guide/services
37Usingaservice
var countryApp = angular.module('countryApp', []);
countryApp.controller('CountryCtrl', ['$scope', '$http', function (scope, http) {
http.get(‘countries.json').success(function(data) {
scope.countries = data;
});
}]);
MAINCONCEPTS/SERVICES /56
Inject $http service using DI
Receive service object
as a parameter
Call method on service
Read More: https://docs.angularjs.org/guide/services
38Creatingaservice
var myModule = angular.module('myModule', []);
myModule.factory('serviceId', function() {
var shinyNewServiceInstance;
//factory function body that constructs shinyNewServiceInstance
return shinyNewServiceInstance;
});
MAINCONCEPTS/SERVICES /56
Return a service instance
Register a new factory function for the service
Read More: https://docs.angularjs.org/guide/services
39Recipes
var myApp = angular.module('myApp',[]);
myApp.provider('MyFactory', function() {...});
myApp.factory('MyFactory', function() {...});
myApp.service('MyFactory', function() {...});
myApp.constant('MyConstant', 'My Constant Value');
myApp.value('MyValue', 35);
MAINCONCEPTS/SERVICES /56
Usingservices
DEMOMAINCONCEPTS
41Multipleviews
 Most applicationsarecomposedof morethan one view
 In Single PageApplicationsall viewsare renderedin the same page
(LayoutTemplate)which containsall the commonpage elements
 Eachview(PartialTemplate)is placedin its own file and dynamically
loadedinto the LayoutTemplate page
MAINCONCEPTS /56
42Multipleviews
MAINCONCEPTS /56
index.html
header.html
a1.html b2.html
a2.html
b1.html
b3.html
a3.html
Layout Template
Partial Template
Partial Template
Partial Template
Partial Template
43Routing
 Routing is providedby the ngRoute module(separatedistribution)
 Routesare declaredvia the $routeProvider fromthe $route service
 Supports deeplinking(history,bookmarksand browserback/forward
buttons)
 Partialviewsarerenderedby the ngView directive
MAINCONCEPTS /56
44Routingconfiguration
var myApp = angular.module('myApp',['ngRoute']);
myApp.config(['$routeProvider',
function($routeProvider) {
$routeProvider.
when('/phones', {
templateUrl: 'partials/phone-list.html',
controller: 'PhoneListCtrl‘
}).
when('/phones/:phoneId', {
templateUrl: 'partials/phone-detail.html',
controller: 'PhoneDetailCtrl'
}).
otherwise({
redirectTo: '/phones'
});
}]);
MAINCONCEPTS/ROUTING /56
Route
Dependency on
ngRoute module
Default Route
Route with variable URL. PhoneId value
will be placed in $routeParams object
Routing
DEMOMAINCONCEPTS
Bestpractices
47BestPractices
 In Views/Templates
 Usedirectivesforabstractingcommonmarkups,extensions
 Donotusecomplexexpressionsinbindings.Movethemtocontrollers.
 Optimizeuseofbindings.Lessbindings=fasterapplication.
 In Controllers
 Keepthemlight.Useservicestooffloadfunctionality.
 NoDOMmanipulations!Usedirectivesforthat.
/56
48BestPractices
 In Directives
 Preferusingdirectivesaselementsorattributesoverclassesandcomments
 Donotng-prefixforyourdirectives
 Createisolatescopestoavoidacidentaloverridesofproperties
 Createmodulesto group controllers,services,directivesand filters
/56
Tools
50Tools
 IDE: Visual Studio, NetBeans,WebStorm
 Utils: JSFiddle, BatarangPlugin for Chrome
 Static Code Analysis:JSHint
 Unit Testing: Karma
/56
Wrappingup
52Wrappingup
 AngularJS is a modular JavaScriptSPA framework
 Has a lot of great featuresbut a steeplearningcurve
 Greatfor CRUD applicationsbut not suitable for everytype of
application
 Worksvery wellwith some JavaScriptlibraries(such as jQuery)but
not so wellwith others
 Increasesdeveloperproductivity in small/medium applicationsbut
can be quite heavyfor complexapplications
/56
53Nexttime...
 Custom directives
 Formcontrolsand validation
 Unit testing
 End-to-endtesting
 Animations
WRAPPINGUP /56
54Resources
Officialdocumentation
 Projecthomepage:https://angularjs.org/
 DeveloperGuide:https://docs.angularjs.org/guide
 Tutorial:https://docs.angularjs.org/tutorial
 APIReference:https://docs.angularjs.org/api
 BuiltwithAngular:https://builtwith.angularjs.org
Trainingvideosandtutorialsfordevelopers
 Egghead:https://egghead.io/technologies/angularjs
Additionalstuff
 Angularmodules:http://ngmodules.org/
WRAPPINGUP /56
ThankYou!
Downloadslidedeck:http://1drv.ms/1h1YOlS
Downloaddemos:http://1drv.ms/1h1YJyP
Working with AngularJS

Contenu connexe

Tendances

Techlunch - Dependency Injection with Vaadin
Techlunch - Dependency Injection with VaadinTechlunch - Dependency Injection with Vaadin
Techlunch - Dependency Injection with VaadinPeter Lehto
 
A gently introduction to AngularJS
A gently introduction to AngularJSA gently introduction to AngularJS
A gently introduction to AngularJSGregor Woiwode
 
Sharper Better Faster Dagger ‡ - Droidcon SF
Sharper Better Faster Dagger ‡ - Droidcon SFSharper Better Faster Dagger ‡ - Droidcon SF
Sharper Better Faster Dagger ‡ - Droidcon SFPierre-Yves Ricau
 
Angular 2 어디까지 왔을까
Angular 2 어디까지 왔을까Angular 2 어디까지 왔을까
Angular 2 어디까지 왔을까장현 한
 
AngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue SolutionsAngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue SolutionsRapidValue
 
Building impressive layout systems with vaadin
Building impressive layout systems with vaadinBuilding impressive layout systems with vaadin
Building impressive layout systems with vaadinPeter Lehto
 
Vaadin Components @ Angular U
Vaadin Components @ Angular UVaadin Components @ Angular U
Vaadin Components @ Angular UJoonas Lehtinen
 
Android DevConference - Android Clean Architecture
Android DevConference - Android Clean ArchitectureAndroid DevConference - Android Clean Architecture
Android DevConference - Android Clean ArchitectureiMasters
 
Different way to share data between controllers in angular js
Different way to share data between controllers in angular jsDifferent way to share data between controllers in angular js
Different way to share data between controllers in angular jscodeandyou forums
 
Angular Mini Hackathon Code Talks 2019
Angular Mini Hackathon Code Talks 2019Angular Mini Hackathon Code Talks 2019
Angular Mini Hackathon Code Talks 2019Maximilian Berghoff
 
Introduction to React for Frontend Developers
Introduction to React for Frontend DevelopersIntroduction to React for Frontend Developers
Introduction to React for Frontend DevelopersSergio Nakamura
 
Vaadin DevDay 2017 - DI your UI
Vaadin DevDay 2017 - DI your UIVaadin DevDay 2017 - DI your UI
Vaadin DevDay 2017 - DI your UIPeter Lehto
 
Introduction to Google Guice
Introduction to Google GuiceIntroduction to Google Guice
Introduction to Google GuiceKnoldus Inc.
 
Modular Test-driven SPAs with Spring and AngularJS
Modular Test-driven SPAs with Spring and AngularJSModular Test-driven SPAs with Spring and AngularJS
Modular Test-driven SPAs with Spring and AngularJSGunnar Hillert
 
Exploring CameraX from JetPack
Exploring CameraX from JetPackExploring CameraX from JetPack
Exploring CameraX from JetPackHassan Abid
 

Tendances (20)

Angular js
Angular jsAngular js
Angular js
 
Techlunch - Dependency Injection with Vaadin
Techlunch - Dependency Injection with VaadinTechlunch - Dependency Injection with Vaadin
Techlunch - Dependency Injection with Vaadin
 
A gently introduction to AngularJS
A gently introduction to AngularJSA gently introduction to AngularJS
A gently introduction to AngularJS
 
Sharper Better Faster Dagger ‡ - Droidcon SF
Sharper Better Faster Dagger ‡ - Droidcon SFSharper Better Faster Dagger ‡ - Droidcon SF
Sharper Better Faster Dagger ‡ - Droidcon SF
 
Angular 2 어디까지 왔을까
Angular 2 어디까지 왔을까Angular 2 어디까지 왔을까
Angular 2 어디까지 왔을까
 
AngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue SolutionsAngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue Solutions
 
Building impressive layout systems with vaadin
Building impressive layout systems with vaadinBuilding impressive layout systems with vaadin
Building impressive layout systems with vaadin
 
Vaadin Components @ Angular U
Vaadin Components @ Angular UVaadin Components @ Angular U
Vaadin Components @ Angular U
 
Android DevConference - Android Clean Architecture
Android DevConference - Android Clean ArchitectureAndroid DevConference - Android Clean Architecture
Android DevConference - Android Clean Architecture
 
Different way to share data between controllers in angular js
Different way to share data between controllers in angular jsDifferent way to share data between controllers in angular js
Different way to share data between controllers in angular js
 
Angular Mini Hackathon Code Talks 2019
Angular Mini Hackathon Code Talks 2019Angular Mini Hackathon Code Talks 2019
Angular Mini Hackathon Code Talks 2019
 
Introduction to React for Frontend Developers
Introduction to React for Frontend DevelopersIntroduction to React for Frontend Developers
Introduction to React for Frontend Developers
 
React django
React djangoReact django
React django
 
Modern android development
Modern android developmentModern android development
Modern android development
 
Building maintainable app
Building maintainable appBuilding maintainable app
Building maintainable app
 
Vaadin DevDay 2017 - DI your UI
Vaadin DevDay 2017 - DI your UIVaadin DevDay 2017 - DI your UI
Vaadin DevDay 2017 - DI your UI
 
Introduction to Google Guice
Introduction to Google GuiceIntroduction to Google Guice
Introduction to Google Guice
 
Vaadin Components
Vaadin ComponentsVaadin Components
Vaadin Components
 
Modular Test-driven SPAs with Spring and AngularJS
Modular Test-driven SPAs with Spring and AngularJSModular Test-driven SPAs with Spring and AngularJS
Modular Test-driven SPAs with Spring and AngularJS
 
Exploring CameraX from JetPack
Exploring CameraX from JetPackExploring CameraX from JetPack
Exploring CameraX from JetPack
 

Similaire à Working with AngularJS

20141002 delapsley-socalangularjs-final
20141002 delapsley-socalangularjs-final20141002 delapsley-socalangularjs-final
20141002 delapsley-socalangularjs-finalDavid Lapsley
 
Handlebars and Require.js
Handlebars and Require.jsHandlebars and Require.js
Handlebars and Require.jsIvano Malavolta
 
Angular JS deep dive
Angular JS deep diveAngular JS deep dive
Angular JS deep diveAxilis
 
AEM Sightly Deep Dive
AEM Sightly Deep DiveAEM Sightly Deep Dive
AEM Sightly Deep DiveGabriel Walt
 
SharePoint Saturday Atlanta 2015
SharePoint Saturday Atlanta 2015SharePoint Saturday Atlanta 2015
SharePoint Saturday Atlanta 2015Pushkar Chivate
 
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJSAngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJSmurtazahaveliwala
 
From Backbone to Ember and Back(bone) Again
From Backbone to Ember and Back(bone) AgainFrom Backbone to Ember and Back(bone) Again
From Backbone to Ember and Back(bone) Againjonknapp
 
بررسی چارچوب جنگو
بررسی چارچوب جنگوبررسی چارچوب جنگو
بررسی چارچوب جنگوrailsbootcamp
 
Angular workshop - Full Development Guide
Angular workshop - Full Development GuideAngular workshop - Full Development Guide
Angular workshop - Full Development GuideNitin Giri
 
Overview of the AngularJS framework
Overview of the AngularJS framework Overview of the AngularJS framework
Overview of the AngularJS framework Yakov Fain
 
Understanding angular js
Understanding angular jsUnderstanding angular js
Understanding angular jsAayush Shrestha
 
AngularJS in 60ish Minutes
AngularJS in 60ish MinutesAngularJS in 60ish Minutes
AngularJS in 60ish MinutesDan Wahlin
 
Adding custom ui controls to your application (1)
Adding custom ui controls to your application (1)Adding custom ui controls to your application (1)
Adding custom ui controls to your application (1)Oro Inc.
 
AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014Ran Wahle
 
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs WorkshopRan Wahle
 
The Google App Engine Oil Framework
The Google App Engine Oil FrameworkThe Google App Engine Oil Framework
The Google App Engine Oil FrameworkEric ShangKuan
 
WJAX 2012 - Web Apps With AngularJS
WJAX 2012 - Web Apps With AngularJSWJAX 2012 - Web Apps With AngularJS
WJAX 2012 - Web Apps With AngularJSPhilipp Burgmer
 

Similaire à Working with AngularJS (20)

20141002 delapsley-socalangularjs-final
20141002 delapsley-socalangularjs-final20141002 delapsley-socalangularjs-final
20141002 delapsley-socalangularjs-final
 
Handlebars and Require.js
Handlebars and Require.jsHandlebars and Require.js
Handlebars and Require.js
 
Angular JS deep dive
Angular JS deep diveAngular JS deep dive
Angular JS deep dive
 
AEM Sightly Deep Dive
AEM Sightly Deep DiveAEM Sightly Deep Dive
AEM Sightly Deep Dive
 
SharePoint Saturday Atlanta 2015
SharePoint Saturday Atlanta 2015SharePoint Saturday Atlanta 2015
SharePoint Saturday Atlanta 2015
 
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJSAngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
 
From Backbone to Ember and Back(bone) Again
From Backbone to Ember and Back(bone) AgainFrom Backbone to Ember and Back(bone) Again
From Backbone to Ember and Back(bone) Again
 
بررسی چارچوب جنگو
بررسی چارچوب جنگوبررسی چارچوب جنگو
بررسی چارچوب جنگو
 
Angular workshop - Full Development Guide
Angular workshop - Full Development GuideAngular workshop - Full Development Guide
Angular workshop - Full Development Guide
 
Overview of the AngularJS framework
Overview of the AngularJS framework Overview of the AngularJS framework
Overview of the AngularJS framework
 
Struts 1
Struts 1Struts 1
Struts 1
 
Understanding angular js
Understanding angular jsUnderstanding angular js
Understanding angular js
 
AngularJS in 60ish Minutes
AngularJS in 60ish MinutesAngularJS in 60ish Minutes
AngularJS in 60ish Minutes
 
Adding custom ui controls to your application (1)
Adding custom ui controls to your application (1)Adding custom ui controls to your application (1)
Adding custom ui controls to your application (1)
 
Handlebars & Require JS
Handlebars  & Require JSHandlebars  & Require JS
Handlebars & Require JS
 
AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014
 
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs Workshop
 
The Google App Engine Oil Framework
The Google App Engine Oil FrameworkThe Google App Engine Oil Framework
The Google App Engine Oil Framework
 
Mean stack Magics
Mean stack MagicsMean stack Magics
Mean stack Magics
 
WJAX 2012 - Web Apps With AngularJS
WJAX 2012 - Web Apps With AngularJSWJAX 2012 - Web Apps With AngularJS
WJAX 2012 - Web Apps With AngularJS
 

Plus de André Vala

RGPD - Testemunho do Mundo Real
RGPD - Testemunho do Mundo RealRGPD - Testemunho do Mundo Real
RGPD - Testemunho do Mundo RealAndré Vala
 
Office Dev Day 2018 - Extending Microsoft Teams
Office Dev Day 2018 - Extending Microsoft TeamsOffice Dev Day 2018 - Extending Microsoft Teams
Office Dev Day 2018 - Extending Microsoft TeamsAndré Vala
 
From Event Receivers to SharePoint Webhooks (SPS Lisbon 2017)
From Event Receivers to SharePoint Webhooks (SPS Lisbon 2017)From Event Receivers to SharePoint Webhooks (SPS Lisbon 2017)
From Event Receivers to SharePoint Webhooks (SPS Lisbon 2017)André Vala
 
From Event Receivers to SharePoint Webhooks
From Event Receivers to SharePoint WebhooksFrom Event Receivers to SharePoint Webhooks
From Event Receivers to SharePoint WebhooksAndré Vala
 
Planning the Death Star with Microsoft Planner
Planning the Death Star with Microsoft PlannerPlanning the Death Star with Microsoft Planner
Planning the Death Star with Microsoft PlannerAndré Vala
 
From Event Receivers to SharePoint Webhooks
From Event Receivers to SharePoint WebhooksFrom Event Receivers to SharePoint Webhooks
From Event Receivers to SharePoint WebhooksAndré Vala
 
Microsoft Planner Deep Dive
Microsoft Planner Deep DiveMicrosoft Planner Deep Dive
Microsoft Planner Deep DiveAndré Vala
 
SharePoint - Presente e Futuro
SharePoint - Presente e FuturoSharePoint - Presente e Futuro
SharePoint - Presente e FuturoAndré Vala
 
Office 365 Groups Deep Dive
Office 365 Groups Deep DiveOffice 365 Groups Deep Dive
Office 365 Groups Deep DiveAndré Vala
 
Soluções com Office Graph
Soluções com Office GraphSoluções com Office Graph
Soluções com Office GraphAndré Vala
 
Host-Named Site Collections in SharePoint 2013
Host-Named Site Collections in SharePoint 2013Host-Named Site Collections in SharePoint 2013
Host-Named Site Collections in SharePoint 2013André Vala
 
User License Enforcement em SharePoint 2013
User License Enforcement em SharePoint 2013User License Enforcement em SharePoint 2013
User License Enforcement em SharePoint 2013André Vala
 
How To Use Host-Named Site Collections
How To Use Host-Named Site CollectionsHow To Use Host-Named Site Collections
How To Use Host-Named Site CollectionsAndré Vala
 
Novidades na pesquisa no SharePoint 2013
Novidades na pesquisa no SharePoint 2013Novidades na pesquisa no SharePoint 2013
Novidades na pesquisa no SharePoint 2013André Vala
 
Building Public Web Sites in SharePoint 2010
Building Public Web Sites in SharePoint 2010 Building Public Web Sites in SharePoint 2010
Building Public Web Sites in SharePoint 2010 André Vala
 
SharePoint + Azure = Better Together
SharePoint + Azure = Better TogetherSharePoint + Azure = Better Together
SharePoint + Azure = Better TogetherAndré Vala
 
Federated Authentication in SharePoint 2010
Federated Authentication in SharePoint 2010Federated Authentication in SharePoint 2010
Federated Authentication in SharePoint 2010André Vala
 
Using BCS to integrate Azure Services with SharePoint 2010
Using BCS to integrate Azure Services with SharePoint 2010Using BCS to integrate Azure Services with SharePoint 2010
Using BCS to integrate Azure Services with SharePoint 2010André Vala
 
LINQ to SharePoint
LINQ to SharePointLINQ to SharePoint
LINQ to SharePointAndré Vala
 
Solução de Negócio baseadas em Office 2010 e SharePoint 2010
Solução de Negócio baseadas em Office 2010 e SharePoint 2010Solução de Negócio baseadas em Office 2010 e SharePoint 2010
Solução de Negócio baseadas em Office 2010 e SharePoint 2010André Vala
 

Plus de André Vala (20)

RGPD - Testemunho do Mundo Real
RGPD - Testemunho do Mundo RealRGPD - Testemunho do Mundo Real
RGPD - Testemunho do Mundo Real
 
Office Dev Day 2018 - Extending Microsoft Teams
Office Dev Day 2018 - Extending Microsoft TeamsOffice Dev Day 2018 - Extending Microsoft Teams
Office Dev Day 2018 - Extending Microsoft Teams
 
From Event Receivers to SharePoint Webhooks (SPS Lisbon 2017)
From Event Receivers to SharePoint Webhooks (SPS Lisbon 2017)From Event Receivers to SharePoint Webhooks (SPS Lisbon 2017)
From Event Receivers to SharePoint Webhooks (SPS Lisbon 2017)
 
From Event Receivers to SharePoint Webhooks
From Event Receivers to SharePoint WebhooksFrom Event Receivers to SharePoint Webhooks
From Event Receivers to SharePoint Webhooks
 
Planning the Death Star with Microsoft Planner
Planning the Death Star with Microsoft PlannerPlanning the Death Star with Microsoft Planner
Planning the Death Star with Microsoft Planner
 
From Event Receivers to SharePoint Webhooks
From Event Receivers to SharePoint WebhooksFrom Event Receivers to SharePoint Webhooks
From Event Receivers to SharePoint Webhooks
 
Microsoft Planner Deep Dive
Microsoft Planner Deep DiveMicrosoft Planner Deep Dive
Microsoft Planner Deep Dive
 
SharePoint - Presente e Futuro
SharePoint - Presente e FuturoSharePoint - Presente e Futuro
SharePoint - Presente e Futuro
 
Office 365 Groups Deep Dive
Office 365 Groups Deep DiveOffice 365 Groups Deep Dive
Office 365 Groups Deep Dive
 
Soluções com Office Graph
Soluções com Office GraphSoluções com Office Graph
Soluções com Office Graph
 
Host-Named Site Collections in SharePoint 2013
Host-Named Site Collections in SharePoint 2013Host-Named Site Collections in SharePoint 2013
Host-Named Site Collections in SharePoint 2013
 
User License Enforcement em SharePoint 2013
User License Enforcement em SharePoint 2013User License Enforcement em SharePoint 2013
User License Enforcement em SharePoint 2013
 
How To Use Host-Named Site Collections
How To Use Host-Named Site CollectionsHow To Use Host-Named Site Collections
How To Use Host-Named Site Collections
 
Novidades na pesquisa no SharePoint 2013
Novidades na pesquisa no SharePoint 2013Novidades na pesquisa no SharePoint 2013
Novidades na pesquisa no SharePoint 2013
 
Building Public Web Sites in SharePoint 2010
Building Public Web Sites in SharePoint 2010 Building Public Web Sites in SharePoint 2010
Building Public Web Sites in SharePoint 2010
 
SharePoint + Azure = Better Together
SharePoint + Azure = Better TogetherSharePoint + Azure = Better Together
SharePoint + Azure = Better Together
 
Federated Authentication in SharePoint 2010
Federated Authentication in SharePoint 2010Federated Authentication in SharePoint 2010
Federated Authentication in SharePoint 2010
 
Using BCS to integrate Azure Services with SharePoint 2010
Using BCS to integrate Azure Services with SharePoint 2010Using BCS to integrate Azure Services with SharePoint 2010
Using BCS to integrate Azure Services with SharePoint 2010
 
LINQ to SharePoint
LINQ to SharePointLINQ to SharePoint
LINQ to SharePoint
 
Solução de Negócio baseadas em Office 2010 e SharePoint 2010
Solução de Negócio baseadas em Office 2010 e SharePoint 2010Solução de Negócio baseadas em Office 2010 e SharePoint 2010
Solução de Negócio baseadas em Office 2010 e SharePoint 2010
 

Dernier

The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
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
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
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
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
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
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
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
 
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
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 

Dernier (20)

The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
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
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.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
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
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
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
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...
 
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
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 

Working with AngularJS

  • 2. 2Aboutme /56 André Vala SharePoint Solutions Architect Office & SharePoint Solutions Team Leader andre.vala@create.pt @atomicvee http://blogit.create.pt/blogs/andrevala http://www.linkedin.com/in/andrevala
  • 3. 3Agenda  What is AngularJS?  Main Concepts  Tools  BestPractices  Wrappingup /56
  • 5. “Angular is what HTML would have been had it been designed for applications.” Miško Hevery
  • 6. 6WhatisAngularJS?  SinglePageApplication(SPA)JavaScriptFramework  Implementsclient-sideMVW pattern  No directDOM manipulation, lesscode  Wellorganizedand highly modular  Focusedon testing  Supports all majordesktopand mobilebrowsers /56 Read More: https://plus.google.com/+AngularJS/posts/aZNVhj355G2
  • 7. 7History  Createdby MiškoHevery  Opensourcesince2009  Supportedby Google  Large and fast-growingcommunity WHATISANGULARJS? /56
  • 8. 8SinglePageApplications  Webapplicationscomposedof a singlepage  Views(HTML Fragments)aredynamicallyloaded into the page  Betteruserexperience(no reloads!)  Calls to the serveraredone asynchronouslybehind the scenes  Requireartificialhandling of browserhistory, navigation and bookmarks WHATISANGULARJS? /56
  • 9. 9Model-View-Whatever  Somecallit MVC, othersMVVM...  In the end, the namedoes not matter. It handles separationof concernsefectivelyseparating presentationlogicfrombusiness logicand presentationstate.  Whatevermeans “whatever worksfor you”. WHATISANGULARJS? /56 Read More: https://plus.google.com/+AngularJS/posts/aZNVhj355G2 Model View Whatever
  • 13. 13Mainconcepts  Templates  Directives  Expressions  Data binding  Scope /56  Controllers  Modules  Filters  Services  Routing
  • 15. 15Helloworldapplication MAINCONCEPTS /56 <!doctype html> <html ng-app> <head> <title>Demo 01 - Page 03</title> <script src="libs/angular.min.js"></script> </head> <body> <p>Name:<input id="textInput" type="text" ng-model="PersonName" /></p> <p>Hello <span id="nameSpan">{{PersonName}}</span>!</p> </body> </html> Directive Directive Expression Template
  • 16. 16Templates  HTML with additional markup  Directives  Expressions  Filters  Formcontrols MAINCONCEPTS /56 Read More: https://docs.angularjs.org/guide/templates
  • 17. 17Directives Markerson DOM elementsthat extendHTML vocabulary  Attachbehaviourtothe DOMelement  TransformtheDOM elementanditschildren Directivescanmatch: Elements <my-dir></my-dir> Attributes <span my-dir="exp"></span> Comments <!-- directive: my-dir exp --> Classes <span class="my-dir: exp;"></span> MAINCONCEPTS /56 Read More: https://docs.angularjs.org/guide/directive
  • 18. 18Namingformats AngularJS HTML compilersupports multiplenamingformats ng-bind Recommendedformat. data-ng-bind Recommendedformattosupport HTMLvalidators. ng_bind Legacypurposes. Avoidusingit. ng:bind Legacypurposes. Avoidusing it. x-ng-bind Legacypurposes. Avoidusing it. MAINCONCEPTS/DIRECTIVES /56 Read More: https://docs.angularjs.org/guide/directive
  • 19. 19Built-indirectives ngApp ngBind ngBindHtml ngBindTemplate ngBlur ngChange ngChecked ngClass ngClassEven ngClassOdd ngClick ngCloak ngController ngCopy ngCsp ngCut ngDblClick ngDisabled ngFocus ngForm ngHide ngHref ngIf ngInclude ngInit ngKeydown ngKeypress ngKeyup ngList ngModel ngModelOptions ngMousedown ngMouseenter ngMouseleave ngMousemove ngMouseover ngNonBindable ngOpen ngPaste ngPluralize ngReadonly ngRepeat ngSelected ngShow ngSrc ngSrcset ngStyle ngSubmit ngTransclude ngValue ngView MAINCONCEPTS/DIRECTIVES /56 Read More: https://docs.angularjs.org/guide/directive
  • 20. 20Expressions JavaScript-likecodesnippetsplacedinsidebindingssuchas {{ expression }} ValidAngularexpressions:  {{ 1 + 2 }}  {{ a + b }}  {{ user.name }}  {{ items[index] }} Additionalnotesaboutexpressions:  Controlflowstatementsarenotsupported(conditionals,loopsorexceptions)  Youcanusefiltersinsideexpressionstoformatdata MAINCONCEPTS /56 Read More: https://docs.angularjs.org/guide/expression
  • 22. 22Databinding Automatic synchronizationof data betweenthe Modeland the View. MAINCONCEPTS /56 Read More: https://docs.angularjs.org/guide/databinding View Template Model One-time merge One-WayDataBinding View Template Model Continuous updates Model is Single-Source-of-Truth Compile Changes to Model updates View Changes to View updates Model Two-WayDataBinding
  • 24. 24Scope  Objectthat refersto the applicationModel  Valuesstored in variablesin the Scopebelong to the Model  The glue betweenthe Controllerand the View  Scopesarehierarchicaland followthe DOM structureof the application  EveryAngular applicationhas a root scope($rootScope)mapped to the elementlinked to ngApp directive MAINCONCEPTS /56 Read More: https://docs.angularjs.org/guide/scope
  • 25. 25Controllers  JavaScriptconstructorfunctions used to augmentthe Scope  Newchild scopeis createdand injectedas a constructor parameter($scope) MAINCONCEPTS /56 Read More: https://docs.angularjs.org/guide/controller
  • 26. 26Howtousecontrollers Creatinga controllerinthe globalnamespace function MyController($scope) { ... } Attachinga controllerto the DOM <div ng-controller="MyController"> MAINCONCEPTS/CONTROLLERS /56 Read More: https://docs.angularjs.org/guide/controller
  • 27. 27Whentousecontrollers  Usecontrollersto:  Setup theinitialstateofthe$scope object  Add behaviourtothe$scope object  Do not use controllersto:  ManipulateDOM(usedatabindinganddirectivesinstead)  Formatinput (useformcontrolsinstead)  Filteroutput (usefiltersinstead)  Sharecodeorstateacrosscontrollers(useservicesinstead) MAINCONCEPTS/CONTROLLERS /56 Read More: https://docs.angularjs.org/guide/controller
  • 29. 29Module  Reusablecontainerfor differentfeaturesof anapp.  Candependon othermodules. Creatinga module angular.module('myApp', []); angular.module('myApp', ['myOtherModule']); Referencinganapp’smainmodule <html ng-app="myApp"> MAINCONCEPTS /56 Read More: https://docs.angularjs.org/guide/module
  • 31. 31Filters  A filterformatsthevalueof anexpressionfor display to the user  Can be used in view templates,controllers,servicesand directives  You can createyour ownfilters (in a module)  Built-in filters: MAINCONCEPTS /56 Read More: https://docs.angularjs.org/guide/filter Currency Date Filter Json LimitTo Lowercase Number OrderBy Uppercase
  • 32. 32Usingfiltersinviewtemplates Singlefiltersyntax {{ expression | filter }} Example:{{ 12 | currency }} returns $12.00 Chainedfilterssyntax {{ expression | filter1 | filter2 | ... }} Filterwitharguments {{ expression | filter:argument1:argument2... }} Example:{{ 12 | number:2 }} returns 12.00 MAINCONCEPTS/FILTERS /56 Read More: https://docs.angularjs.org/guide/filter
  • 33. 33Usingfiltersincontrollers,servicesanddirectives angular.module('FilterInControllerModule', []). controller('FilterController', ['filterFilter', function(filterFilter) { this.array = [ {name: 'Tobias'}, {name: 'Jeff'}, {name: 'Brian'}, {name: 'Igor'}, {name: 'James'}, {name: 'Brad'} ]; this.filteredArray = filterFilter(this.array, 'a'); }]); MAINCONCEPTS/FILTERS /56 Read More: https://docs.angularjs.org/guide/filter Inject filter in controller using <filter name>Filter syntax Receive filter function as a parameter Call filter with value to format and additional parameters
  • 34. 34Creatingfilters angular.module('MyFilterModule', []). filter('myfilter', function() { return function(input) { ... return output; }; }); MAINCONCEPTS/FILTERS /56 Read More: https://docs.angularjs.org/guide/filter User the filter provider to create a new filter in the module Name the filter Return the filter function. The first argument is the input value. Additional arguments can be used.
  • 36. 36Services  Reusablebusiness logiccomponentes,independentof views,wired togetherusing dependencyinjection(DI).  Singletonsgeneratedby a servicefactory.  Angular only instantiatesa serviceif thereis a dependencyfor it.  Built-in servicesstart with $. Examples:$log, $http, $filter,$exceptionHandler MAINCONCEPTS /56 Read More: https://docs.angularjs.org/guide/services
  • 37. 37Usingaservice var countryApp = angular.module('countryApp', []); countryApp.controller('CountryCtrl', ['$scope', '$http', function (scope, http) { http.get(‘countries.json').success(function(data) { scope.countries = data; }); }]); MAINCONCEPTS/SERVICES /56 Inject $http service using DI Receive service object as a parameter Call method on service Read More: https://docs.angularjs.org/guide/services
  • 38. 38Creatingaservice var myModule = angular.module('myModule', []); myModule.factory('serviceId', function() { var shinyNewServiceInstance; //factory function body that constructs shinyNewServiceInstance return shinyNewServiceInstance; }); MAINCONCEPTS/SERVICES /56 Return a service instance Register a new factory function for the service Read More: https://docs.angularjs.org/guide/services
  • 39. 39Recipes var myApp = angular.module('myApp',[]); myApp.provider('MyFactory', function() {...}); myApp.factory('MyFactory', function() {...}); myApp.service('MyFactory', function() {...}); myApp.constant('MyConstant', 'My Constant Value'); myApp.value('MyValue', 35); MAINCONCEPTS/SERVICES /56
  • 41. 41Multipleviews  Most applicationsarecomposedof morethan one view  In Single PageApplicationsall viewsare renderedin the same page (LayoutTemplate)which containsall the commonpage elements  Eachview(PartialTemplate)is placedin its own file and dynamically loadedinto the LayoutTemplate page MAINCONCEPTS /56
  • 42. 42Multipleviews MAINCONCEPTS /56 index.html header.html a1.html b2.html a2.html b1.html b3.html a3.html Layout Template Partial Template Partial Template Partial Template Partial Template
  • 43. 43Routing  Routing is providedby the ngRoute module(separatedistribution)  Routesare declaredvia the $routeProvider fromthe $route service  Supports deeplinking(history,bookmarksand browserback/forward buttons)  Partialviewsarerenderedby the ngView directive MAINCONCEPTS /56
  • 44. 44Routingconfiguration var myApp = angular.module('myApp',['ngRoute']); myApp.config(['$routeProvider', function($routeProvider) { $routeProvider. when('/phones', { templateUrl: 'partials/phone-list.html', controller: 'PhoneListCtrl‘ }). when('/phones/:phoneId', { templateUrl: 'partials/phone-detail.html', controller: 'PhoneDetailCtrl' }). otherwise({ redirectTo: '/phones' }); }]); MAINCONCEPTS/ROUTING /56 Route Dependency on ngRoute module Default Route Route with variable URL. PhoneId value will be placed in $routeParams object
  • 47. 47BestPractices  In Views/Templates  Usedirectivesforabstractingcommonmarkups,extensions  Donotusecomplexexpressionsinbindings.Movethemtocontrollers.  Optimizeuseofbindings.Lessbindings=fasterapplication.  In Controllers  Keepthemlight.Useservicestooffloadfunctionality.  NoDOMmanipulations!Usedirectivesforthat. /56
  • 48. 48BestPractices  In Directives  Preferusingdirectivesaselementsorattributesoverclassesandcomments  Donotng-prefixforyourdirectives  Createisolatescopestoavoidacidentaloverridesofproperties  Createmodulesto group controllers,services,directivesand filters /56
  • 49. Tools
  • 50. 50Tools  IDE: Visual Studio, NetBeans,WebStorm  Utils: JSFiddle, BatarangPlugin for Chrome  Static Code Analysis:JSHint  Unit Testing: Karma /56
  • 52. 52Wrappingup  AngularJS is a modular JavaScriptSPA framework  Has a lot of great featuresbut a steeplearningcurve  Greatfor CRUD applicationsbut not suitable for everytype of application  Worksvery wellwith some JavaScriptlibraries(such as jQuery)but not so wellwith others  Increasesdeveloperproductivity in small/medium applicationsbut can be quite heavyfor complexapplications /56
  • 53. 53Nexttime...  Custom directives  Formcontrolsand validation  Unit testing  End-to-endtesting  Animations WRAPPINGUP /56
  • 54. 54Resources Officialdocumentation  Projecthomepage:https://angularjs.org/  DeveloperGuide:https://docs.angularjs.org/guide  Tutorial:https://docs.angularjs.org/tutorial  APIReference:https://docs.angularjs.org/api  BuiltwithAngular:https://builtwith.angularjs.org Trainingvideosandtutorialsfordevelopers  Egghead:https://egghead.io/technologies/angularjs Additionalstuff  Angularmodules:http://ngmodules.org/ WRAPPINGUP /56