SlideShare a Scribd company logo
Angular JS
A brief Introduction
What is AngularJS
MVC Javascript Framework by Google for Rich
Web Application Development
Why AngularJS
“Other frameworks deal with HTML’s shortcomings by either abstracting away
HTML, CSS, and/or JavaScript or by providing an imperative way for manipulating
the DOM. Neither of these address the root problem that HTML was not designed
for dynamic views”.
• Structure, Quality and Organization
• Lightweight ( < 36KB compressed and minified)
• Free
• Separation of concern
• Modularity
• Extensibility & Maintainability
• Reusable Components
“ HTML? Build UI Declaratively! CSS? Animations! JavaScript? Use it the plain old way!”
jQuery
• Allows for DOM Manipulation
• Does not provide structure to your code
• Does not allow for two way binding
Other Javascript MV* Frameworks
• BackboneJS
• EmberJS
Features of AngularJS
• Two-way Data Binding – Model as single
source of truth
• Directives – Extend HTML
• MVC
• Dependency Injection
• Testing
• Deep Linking (Map URL to route Definition)
• Server-Side Communication
Data Binding
<html ng-app>
<head>
<script src='angular.js'></script>
</head>
<body>
<input ng-model='user.name'>
<div ng-show='user.name'>Hi {{user.name}}</div>
</body>
</html>
MVC
Model (Data)
Controller
(Logic)
View (UI)
Notifies
Notifies
Changes
MVC
Controller
Model
View
JS Classes
DOM
JS Objects
MVC
<html ng-app>
<head>
<script src='angular.js'></script>
<script src='controllers.js'></script>
</head>
<body ng-controller='UserController'>
<div>Hi {{user.name}}</div>
</body>
</html>
function XXXX($scope) {
$scope.user = { name:'Larry' };
}
Hello HTML
<p>Hello World!</p>
Hello Javascript
<p id="greeting1"></p>
<script>
var isIE = document.attachEvent;
var addListener = isIE
? function(e, t, fn) {
e.attachEvent('on' + t, fn);}
: function(e, t, fn) {
e.addEventListener(t, fn, false);};
addListener(document, 'load', function(){
var greeting = document.getElementById('greeting1');
if (isIE) {
greeting.innerText = 'Hello World!';
} else {
greeting.textContent = 'Hello World!';
}
});
</script>
Hello JQuery
<p id="greeting2"></p>
<script>
$(function(){
$('#greeting2').text('Hello World!');
});
</script>
Hello AngularJS
<p ng:init="greeting = 'Hello World!'">{{greeting}}</p>
DEMONSTRATION!!!!!
Feeder App
http://www.toptal.com/angular-js/a-step-by-step-guide-to-your-first-angularjs-app
App Skeleton
Final View (Championship Table)
Sample Angular Powered View
<body ng-app="F1FeederApp" ng-controller="driversController">
<table>
<thead>
<tr><th colspan="4">Drivers Championship Standings</th></tr>
</thead>
<tbody>
<tr ng-repeat="driver in driversList">
<td>{{$index + 1}}</td>
<td>
<img src="img/flags/{{driver.Driver.nationality}}.png" />
{{driver.Driver.givenName}}&nbsp;{{driver.Driver.familyName}}
</td>
<td>{{driver.Constructors[0].name}}</td>
<td>{{driver.points}}</td>
</tr>
</tbody>
</table>
</body>
Expressions
Expressions allow you to execute some
computation in order to return a desired value.
• {{ 1 + 1 }}
• {{ 946757880 | date }}
• {{ user.name }}
you shouldn’t use expressions to implement any
higher-level logic.
Directives
Directives are markers (such as attributes, tags, and
class names) that tell AngularJS to attach a given
behaviour to a DOM element (or transform it, replace
it, etc.)
Some angular directives
• The ng-app - Bootstrapping your app and defining its
scope.
• The ng-controller - defines which controller will be in
charge of your view.
• The ng-repeat - Allows for looping through collections
Directives as Components
<rating max='5' model='stars.average'>
<tabs>
<tab title='Active tab' view='...'>
<tab title='Inactive tab' view='...'>
</tabs>
<tooltip content='messages.tip1'>
Adding Controllers
angular.module('F1FeederApp.controllers', []).
controller('driversController', function($scope) {
$scope.driversList = [
{
Driver: {
givenName: 'Sebastian',
familyName: 'Vettel'
},
points: 322,
nationality: "German",
Constructors: [
{name: "Red Bull"}
]
},
{
Driver: {
givenName: 'Fernando',
familyName: 'Alonso'
},
points: 207,
nationality: "Spanish",
Constructors: [
{name: "Ferrari"}
]
}
];
});
• The $scope variable –
Link your controllers
and view
App.js
angular.module('F1FeederApp', [
'F1FeederApp.controllers'
]);
Initializes our app and register the modules on
which it depends
Index.html
<body ng-app="F1FeederApp" ng-controller="driversController">
<table>
<thead>
<tr><th colspan="4">Drivers Championship Standings</th></tr>
</thead>
<tbody>
<tr ng-repeat="driver in driversList">
<td>{{$index + 1}}</td>
<td>
<img src="img/flags/{{driver.Driver.nationality}}.png" />
{{driver.Driver.givenName}}&nbsp;{{driver.Driver.familyName}}
</td>
<td>{{driver.Constructors[0].name}}</td>
<td>{{driver.points}}</td>
</tr>
</tbody>
</table>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="js/app.js"></script>
<script src="js/services.js"></script>
<script src="js/controllers.js"></script>
</body>
</html>
Loading data from the
server(services.js)
angular.module('F1FeederApp.services', []).
factory('ergastAPIservice', function($http) {
var ergastAPI = {};
ergastAPI.getDrivers = function() {
return $http({
method: 'JSONP',
url:
'http://ergast.com/api/f1/2013/driverStandi
ngs.json?callback=JSON_CALLBACK'
});
}
return ergastAPI;
});
• $http - a layer on top
of XMLHttpRequest or JSONP
• $resource - provides a higher level of
abstraction
• Dependency Injection
we create a new module
(F1FeederApp.services) and register a service
within that module (ergastAPIservice).
Modified controller.js
angular.module('F1FeederApp.controllers', []).
controller('driversController', function($scope, ergastAPIservice) {
$scope.nameFilter = null;
$scope.driversList = [];
ergastAPIservice.getDrivers().success(function (response) {
//Dig into the responde to get the relevant data
$scope.driversList =
response.MRData.StandingsTable.StandingsLists[0].DriverStandings;
});
});
Routes
• $routeProvider – used for dealing with routes
Modified app.js
angular.module('F1FeederApp', [
'F1FeederApp.services',
'F1FeederApp.controllers',
'ngRoute'
]).
config(['$routeProvider', function($routeProvider) {
$routeProvider.
when("/drivers", {templateUrl: "partials/drivers.html", controller: "driversController"}).
when("/drivers/:id", {templateUrl: "partials/driver.html", controller: "driverController"}).
otherwise({redirectTo: '/drivers'});
}]);
Partial views
<!DOCTYPE html>
<html>
<head>
<title>F-1 Feeder</title>
</head>
<body ng-app="F1FeederApp">
<ng-view></ng-view>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="js/app.js"></script>
<script src="js/services.js"></script>
<script src="js/controllers.js"></script>
</body>
</html>
Advanced AngularJS Concept
• Dependency Injection
• Modularity
• Digesting
• Scope
• Handling SEO
• End to End Testing
• Promises
• Localization
• Filters
Useful Links
• https://angularjs.org/
• http://campus.codeschool.com/courses/shapi
ng-up-with-angular-js/contents
• http://www.toptal.com/angular-js/a-step-by-
step-guide-to-your-first-angularjs-app
• https://github.com/raonibr/f1feeder-part1

More Related Content

What's hot (20)

PDF
Angularjs architecture
Michael He
 
PPTX
Angular js architecture (v1.4.8)
Gabi Costel Lapusneanu
 
PPTX
Angular js
Dinusha Nandika
 
PDF
Introduction to AngularJS
Jussi Pohjolainen
 
PDF
Advanced Tips & Tricks for using Angular JS
Simon Guest
 
PDF
AngularJS 101 - Everything you need to know to get started
Stéphane Bégaudeau
 
PPTX
Understanding angular js
Aayush Shrestha
 
KEY
AngularJS for designers and developers
Kai Koenig
 
PPTX
Step by Step - AngularJS
Infragistics
 
PDF
AngularJS - What is it & Why is it awesome ? (with demos)
Gary Arora
 
PPTX
Why angular js Framework
Sakthi Bro
 
PDF
AngularJS application architecture
Gabriele Falace
 
PPTX
Angular js
Behind D Walls
 
PPTX
AngularJS Best Practices
Narek Mamikonyan
 
PPTX
Introduction to Angular js 2.0
Nagaraju Sangam
 
PPTX
AngularJS - Architecture decisions in a large project 
Elad Hirsch
 
PPTX
Practical AngularJS
Wei Ru
 
PDF
AngularJS: an introduction
Luigi De Russis
 
PPTX
AngularJS intro
dizabl
 
PPTX
Angular Js Basics
أحمد عبد الوهاب
 
Angularjs architecture
Michael He
 
Angular js architecture (v1.4.8)
Gabi Costel Lapusneanu
 
Angular js
Dinusha Nandika
 
Introduction to AngularJS
Jussi Pohjolainen
 
Advanced Tips & Tricks for using Angular JS
Simon Guest
 
AngularJS 101 - Everything you need to know to get started
Stéphane Bégaudeau
 
Understanding angular js
Aayush Shrestha
 
AngularJS for designers and developers
Kai Koenig
 
Step by Step - AngularJS
Infragistics
 
AngularJS - What is it & Why is it awesome ? (with demos)
Gary Arora
 
Why angular js Framework
Sakthi Bro
 
AngularJS application architecture
Gabriele Falace
 
Angular js
Behind D Walls
 
AngularJS Best Practices
Narek Mamikonyan
 
Introduction to Angular js 2.0
Nagaraju Sangam
 
AngularJS - Architecture decisions in a large project 
Elad Hirsch
 
Practical AngularJS
Wei Ru
 
AngularJS: an introduction
Luigi De Russis
 
AngularJS intro
dizabl
 
Angular Js Basics
أحمد عبد الوهاب
 

Viewers also liked (15)

PPTX
Angular js
ParmarAnisha
 
PDF
Design patterns through refactoring
Ganesh Samarthyam
 
PDF
Design Patterns in .Net
Dmitri Nesteruk
 
PDF
Creational Design Patterns
Jamie (Taka) Wang
 
PDF
Angular JS blog tutorial
Claude Tech
 
PPTX
Node js meetup
Ansuman Roy
 
PPTX
Get satrted angular js
Alexandre Marreiros
 
PPTX
Angular 2
Nigam Goyal
 
PPTX
Introduction to Node js
Akshay Mathur
 
PDF
Object-oriented design patterns in UML [Software Modeling] [Computer Science...
Ivano Malavolta
 
PPT
Design Patterns
soms_1
 
PDF
Modern UI Development With Node.js
Ryan Anklam
 
PPT
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
Svetlin Nakov
 
PPT
Design Patterns (Examples in .NET)
Aniruddha Chakrabarti
 
PDF
Design Patterns Illustrated
Herman Peeren
 
Angular js
ParmarAnisha
 
Design patterns through refactoring
Ganesh Samarthyam
 
Design Patterns in .Net
Dmitri Nesteruk
 
Creational Design Patterns
Jamie (Taka) Wang
 
Angular JS blog tutorial
Claude Tech
 
Node js meetup
Ansuman Roy
 
Get satrted angular js
Alexandre Marreiros
 
Angular 2
Nigam Goyal
 
Introduction to Node js
Akshay Mathur
 
Object-oriented design patterns in UML [Software Modeling] [Computer Science...
Ivano Malavolta
 
Design Patterns
soms_1
 
Modern UI Development With Node.js
Ryan Anklam
 
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
Svetlin Nakov
 
Design Patterns (Examples in .NET)
Aniruddha Chakrabarti
 
Design Patterns Illustrated
Herman Peeren
 
Ad

Similar to Angular js (20)

PPTX
Angular js
Radheshyam Kori
 
PPTX
Angular js
Radheshyam Kori
 
PPTX
Best Angularjs tutorial for beginners - TIB Academy
TIB Academy
 
PDF
Wt unit 5 client &amp; server side framework
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
PDF
Introduction to AngularJS By Bharat Makwana
Bharat Makwana
 
PPTX
Introduction to single page application with angular js
Mindfire Solutions
 
PPTX
Intoduction to Angularjs
Gaurav Agrawal
 
PPTX
Angular js anupama
Anupama Prabhudesai
 
PPTX
Angularjs
Sabin Tamrakar
 
PPTX
Angular Javascript Tutorial with command
ssuser42b933
 
PPTX
ANGULARJS introduction components services and directives
SanthoshB77
 
PPTX
AngularJS is awesome
Eusebiu Schipor
 
PPTX
AngularJS Introduction, how to run Angular
SamuelJohnpeter
 
PDF
Introduction to Angularjs : kishan kumar
Appfinz Technologies
 
PPTX
AgularJS basics- angular directives and controllers
jobinThomas54
 
PPTX
Introduction to AngularJS
Shyjal Raazi
 
PPTX
Angularjs basic part01
Mohd Abdul Baquee
 
PPTX
Angular workshop - Full Development Guide
Nitin Giri
 
PPTX
ME vs WEB - AngularJS Fundamentals
Aviran Cohen
 
Angular js
Radheshyam Kori
 
Angular js
Radheshyam Kori
 
Best Angularjs tutorial for beginners - TIB Academy
TIB Academy
 
Wt unit 5 client &amp; server side framework
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
Introduction to AngularJS By Bharat Makwana
Bharat Makwana
 
Introduction to single page application with angular js
Mindfire Solutions
 
Intoduction to Angularjs
Gaurav Agrawal
 
Angular js anupama
Anupama Prabhudesai
 
Angularjs
Sabin Tamrakar
 
Angular Javascript Tutorial with command
ssuser42b933
 
ANGULARJS introduction components services and directives
SanthoshB77
 
AngularJS is awesome
Eusebiu Schipor
 
AngularJS Introduction, how to run Angular
SamuelJohnpeter
 
Introduction to Angularjs : kishan kumar
Appfinz Technologies
 
AgularJS basics- angular directives and controllers
jobinThomas54
 
Introduction to AngularJS
Shyjal Raazi
 
Angularjs basic part01
Mohd Abdul Baquee
 
Angular workshop - Full Development Guide
Nitin Giri
 
ME vs WEB - AngularJS Fundamentals
Aviran Cohen
 
Ad

More from Manav Prasad (20)

PPTX
Experience with mulesoft
Manav Prasad
 
PPTX
Mulesoftconnectors
Manav Prasad
 
PPT
Mule and web services
Manav Prasad
 
PPTX
Mulesoft cloudhub
Manav Prasad
 
PPT
Perl tutorial
Manav Prasad
 
PPT
Hibernate presentation
Manav Prasad
 
PPT
Jpa
Manav Prasad
 
PPT
Spring introduction
Manav Prasad
 
PPT
Json
Manav Prasad
 
PPT
The spring framework
Manav Prasad
 
PPT
Rest introduction
Manav Prasad
 
PPT
Exceptions in java
Manav Prasad
 
PPT
Junit
Manav Prasad
 
PPT
Xml parsers
Manav Prasad
 
PPT
Xpath
Manav Prasad
 
PPT
Xslt
Manav Prasad
 
PPT
Xhtml
Manav Prasad
 
PPT
Css
Manav Prasad
 
PPT
Introduction to html5
Manav Prasad
 
PPT
Ajax
Manav Prasad
 
Experience with mulesoft
Manav Prasad
 
Mulesoftconnectors
Manav Prasad
 
Mule and web services
Manav Prasad
 
Mulesoft cloudhub
Manav Prasad
 
Perl tutorial
Manav Prasad
 
Hibernate presentation
Manav Prasad
 
Spring introduction
Manav Prasad
 
The spring framework
Manav Prasad
 
Rest introduction
Manav Prasad
 
Exceptions in java
Manav Prasad
 
Xml parsers
Manav Prasad
 
Introduction to html5
Manav Prasad
 

Recently uploaded (20)

PPTX
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
PDF
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
PPTX
Shinkawa Proposal to meet Vibration API670.pptx
AchmadBashori2
 
PPTX
Introduction to Basic Renewable Energy.pptx
examcoordinatormesu
 
PDF
Zilliz Cloud Demo for performance and scale
Zilliz
 
PPTX
Introduction to Design of Machine Elements
PradeepKumarS27
 
PDF
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
PPTX
Thermal runway and thermal stability.pptx
godow93766
 
PPTX
Element 11. ELECTRICITY safety and hazards
merrandomohandas
 
PPT
Carmon_Remote Sensing GIS by Mahesh kumar
DhananjayM6
 
PPTX
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
PDF
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
PPTX
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
PPTX
Big Data and Data Science hype .pptx
SUNEEL37
 
PDF
Design Thinking basics for Engineers.pdf
CMR University
 
DOCX
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
PDF
Electrical Engineer operation Supervisor
ssaruntatapower143
 
PPTX
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
PDF
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
PDF
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
Shinkawa Proposal to meet Vibration API670.pptx
AchmadBashori2
 
Introduction to Basic Renewable Energy.pptx
examcoordinatormesu
 
Zilliz Cloud Demo for performance and scale
Zilliz
 
Introduction to Design of Machine Elements
PradeepKumarS27
 
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
Thermal runway and thermal stability.pptx
godow93766
 
Element 11. ELECTRICITY safety and hazards
merrandomohandas
 
Carmon_Remote Sensing GIS by Mahesh kumar
DhananjayM6
 
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
Big Data and Data Science hype .pptx
SUNEEL37
 
Design Thinking basics for Engineers.pdf
CMR University
 
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
Electrical Engineer operation Supervisor
ssaruntatapower143
 
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 

Angular js

  • 1. Angular JS A brief Introduction
  • 2. What is AngularJS MVC Javascript Framework by Google for Rich Web Application Development
  • 3. Why AngularJS “Other frameworks deal with HTML’s shortcomings by either abstracting away HTML, CSS, and/or JavaScript or by providing an imperative way for manipulating the DOM. Neither of these address the root problem that HTML was not designed for dynamic views”. • Structure, Quality and Organization • Lightweight ( < 36KB compressed and minified) • Free • Separation of concern • Modularity • Extensibility & Maintainability • Reusable Components “ HTML? Build UI Declaratively! CSS? Animations! JavaScript? Use it the plain old way!”
  • 4. jQuery • Allows for DOM Manipulation • Does not provide structure to your code • Does not allow for two way binding
  • 5. Other Javascript MV* Frameworks • BackboneJS • EmberJS
  • 6. Features of AngularJS • Two-way Data Binding – Model as single source of truth • Directives – Extend HTML • MVC • Dependency Injection • Testing • Deep Linking (Map URL to route Definition) • Server-Side Communication
  • 7. Data Binding <html ng-app> <head> <script src='angular.js'></script> </head> <body> <input ng-model='user.name'> <div ng-show='user.name'>Hi {{user.name}}</div> </body> </html>
  • 10. MVC <html ng-app> <head> <script src='angular.js'></script> <script src='controllers.js'></script> </head> <body ng-controller='UserController'> <div>Hi {{user.name}}</div> </body> </html> function XXXX($scope) { $scope.user = { name:'Larry' }; }
  • 12. Hello Javascript <p id="greeting1"></p> <script> var isIE = document.attachEvent; var addListener = isIE ? function(e, t, fn) { e.attachEvent('on' + t, fn);} : function(e, t, fn) { e.addEventListener(t, fn, false);}; addListener(document, 'load', function(){ var greeting = document.getElementById('greeting1'); if (isIE) { greeting.innerText = 'Hello World!'; } else { greeting.textContent = 'Hello World!'; } }); </script>
  • 14. Hello AngularJS <p ng:init="greeting = 'Hello World!'">{{greeting}}</p>
  • 18. Sample Angular Powered View <body ng-app="F1FeederApp" ng-controller="driversController"> <table> <thead> <tr><th colspan="4">Drivers Championship Standings</th></tr> </thead> <tbody> <tr ng-repeat="driver in driversList"> <td>{{$index + 1}}</td> <td> <img src="img/flags/{{driver.Driver.nationality}}.png" /> {{driver.Driver.givenName}}&nbsp;{{driver.Driver.familyName}} </td> <td>{{driver.Constructors[0].name}}</td> <td>{{driver.points}}</td> </tr> </tbody> </table> </body>
  • 19. Expressions Expressions allow you to execute some computation in order to return a desired value. • {{ 1 + 1 }} • {{ 946757880 | date }} • {{ user.name }} you shouldn’t use expressions to implement any higher-level logic.
  • 20. Directives Directives are markers (such as attributes, tags, and class names) that tell AngularJS to attach a given behaviour to a DOM element (or transform it, replace it, etc.) Some angular directives • The ng-app - Bootstrapping your app and defining its scope. • The ng-controller - defines which controller will be in charge of your view. • The ng-repeat - Allows for looping through collections
  • 21. Directives as Components <rating max='5' model='stars.average'> <tabs> <tab title='Active tab' view='...'> <tab title='Inactive tab' view='...'> </tabs> <tooltip content='messages.tip1'>
  • 22. Adding Controllers angular.module('F1FeederApp.controllers', []). controller('driversController', function($scope) { $scope.driversList = [ { Driver: { givenName: 'Sebastian', familyName: 'Vettel' }, points: 322, nationality: "German", Constructors: [ {name: "Red Bull"} ] }, { Driver: { givenName: 'Fernando', familyName: 'Alonso' }, points: 207, nationality: "Spanish", Constructors: [ {name: "Ferrari"} ] } ]; }); • The $scope variable – Link your controllers and view
  • 24. Index.html <body ng-app="F1FeederApp" ng-controller="driversController"> <table> <thead> <tr><th colspan="4">Drivers Championship Standings</th></tr> </thead> <tbody> <tr ng-repeat="driver in driversList"> <td>{{$index + 1}}</td> <td> <img src="img/flags/{{driver.Driver.nationality}}.png" /> {{driver.Driver.givenName}}&nbsp;{{driver.Driver.familyName}} </td> <td>{{driver.Constructors[0].name}}</td> <td>{{driver.points}}</td> </tr> </tbody> </table> <script src="bower_components/angular/angular.js"></script> <script src="bower_components/angular-route/angular-route.js"></script> <script src="js/app.js"></script> <script src="js/services.js"></script> <script src="js/controllers.js"></script> </body> </html>
  • 25. Loading data from the server(services.js) angular.module('F1FeederApp.services', []). factory('ergastAPIservice', function($http) { var ergastAPI = {}; ergastAPI.getDrivers = function() { return $http({ method: 'JSONP', url: 'http://ergast.com/api/f1/2013/driverStandi ngs.json?callback=JSON_CALLBACK' }); } return ergastAPI; }); • $http - a layer on top of XMLHttpRequest or JSONP • $resource - provides a higher level of abstraction • Dependency Injection we create a new module (F1FeederApp.services) and register a service within that module (ergastAPIservice).
  • 26. Modified controller.js angular.module('F1FeederApp.controllers', []). controller('driversController', function($scope, ergastAPIservice) { $scope.nameFilter = null; $scope.driversList = []; ergastAPIservice.getDrivers().success(function (response) { //Dig into the responde to get the relevant data $scope.driversList = response.MRData.StandingsTable.StandingsLists[0].DriverStandings; }); });
  • 27. Routes • $routeProvider – used for dealing with routes Modified app.js angular.module('F1FeederApp', [ 'F1FeederApp.services', 'F1FeederApp.controllers', 'ngRoute' ]). config(['$routeProvider', function($routeProvider) { $routeProvider. when("/drivers", {templateUrl: "partials/drivers.html", controller: "driversController"}). when("/drivers/:id", {templateUrl: "partials/driver.html", controller: "driverController"}). otherwise({redirectTo: '/drivers'}); }]);
  • 28. Partial views <!DOCTYPE html> <html> <head> <title>F-1 Feeder</title> </head> <body ng-app="F1FeederApp"> <ng-view></ng-view> <script src="bower_components/angular/angular.js"></script> <script src="bower_components/angular-route/angular-route.js"></script> <script src="js/app.js"></script> <script src="js/services.js"></script> <script src="js/controllers.js"></script> </body> </html>
  • 29. Advanced AngularJS Concept • Dependency Injection • Modularity • Digesting • Scope • Handling SEO • End to End Testing • Promises • Localization • Filters
  • 30. Useful Links • https://angularjs.org/ • http://campus.codeschool.com/courses/shapi ng-up-with-angular-js/contents • http://www.toptal.com/angular-js/a-step-by- step-guide-to-your-first-angularjs-app • https://github.com/raonibr/f1feeder-part1