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

PPTX
Angular JS - Introduction
PPTX
Angular JS
PPTX
Introduction to Angularjs
PPTX
Front end development with Angular JS
PDF
AngularJS introduction
PPTX
The AngularJS way
PPTX
Getting Started with Angular JS
PDF
AngularJS Basic Training
Angular JS - Introduction
Angular JS
Introduction to Angularjs
Front end development with Angular JS
AngularJS introduction
The AngularJS way
Getting Started with Angular JS
AngularJS Basic Training

What's hot (20)

PDF
Angularjs architecture
PPTX
Angular js architecture (v1.4.8)
PPTX
Angular js
PDF
Introduction to AngularJS
PDF
Advanced Tips & Tricks for using Angular JS
PDF
AngularJS 101 - Everything you need to know to get started
PPTX
Understanding angular js
KEY
AngularJS for designers and developers
PPTX
Step by Step - AngularJS
PDF
AngularJS - What is it & Why is it awesome ? (with demos)
PPTX
Why angular js Framework
PDF
AngularJS application architecture
PPTX
Angular js
PPTX
AngularJS Best Practices
PPTX
Introduction to Angular js 2.0
PPTX
AngularJS - Architecture decisions in a large project 
PPTX
Practical AngularJS
PDF
AngularJS: an introduction
PPTX
AngularJS intro
PPTX
Angular Js Basics
Angularjs architecture
Angular js architecture (v1.4.8)
Angular js
Introduction to AngularJS
Advanced Tips & Tricks for using Angular JS
AngularJS 101 - Everything you need to know to get started
Understanding angular js
AngularJS for designers and developers
Step by Step - AngularJS
AngularJS - What is it & Why is it awesome ? (with demos)
Why angular js Framework
AngularJS application architecture
Angular js
AngularJS Best Practices
Introduction to Angular js 2.0
AngularJS - Architecture decisions in a large project 
Practical AngularJS
AngularJS: an introduction
AngularJS intro
Angular Js Basics
Ad

Viewers also liked (15)

PPTX
Angular js
PDF
Design patterns through refactoring
PDF
Design Patterns in .Net
PDF
Creational Design Patterns
PDF
Angular JS blog tutorial
PPTX
Node js meetup
PPTX
Get satrted angular js
PPTX
Angular 2
PPTX
Introduction to Node js
PDF
Object-oriented design patterns in UML [Software Modeling] [Computer Science...
PPT
Design Patterns
PDF
Modern UI Development With Node.js
PPT
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
PPT
Design Patterns (Examples in .NET)
PDF
Design Patterns Illustrated
Angular js
Design patterns through refactoring
Design Patterns in .Net
Creational Design Patterns
Angular JS blog tutorial
Node js meetup
Get satrted angular js
Angular 2
Introduction to Node js
Object-oriented design patterns in UML [Software Modeling] [Computer Science...
Design Patterns
Modern UI Development With Node.js
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
Design Patterns (Examples in .NET)
Design Patterns Illustrated
Ad

Similar to Angular js (20)

PPTX
Best Angularjs tutorial for beginners - TIB Academy
PPTX
Angular js anupama
PPTX
Learning AngularJS - Complete coverage of AngularJS features and concepts
PPTX
ME vs WEB - AngularJS Fundamentals
PDF
Introduction to Angular Js
PDF
Angular JS tutorial
PPTX
AngularJs (1.x) Presentation
PPTX
Introduction to AngularJS
PPTX
Angular patterns
PPTX
Angular js
PPTX
AngularJS - GrapeCity Echo Tokyo
PPTX
Angular JS, A dive to concepts
PDF
AngularJS Workshop
PPTX
AngularJs Workshop SDP December 28th 2014
PDF
Introduction to Angularjs : kishan kumar
PPTX
angularJs Workshop
PPTX
Angular JS Indtrodution
PDF
What Is Angular 2 | Angular 2 Tutorial For Beginners | Angular Training | Edu...
PPTX
Angular js
Best Angularjs tutorial for beginners - TIB Academy
Angular js anupama
Learning AngularJS - Complete coverage of AngularJS features and concepts
ME vs WEB - AngularJS Fundamentals
Introduction to Angular Js
Angular JS tutorial
AngularJs (1.x) Presentation
Introduction to AngularJS
Angular patterns
Angular js
AngularJS - GrapeCity Echo Tokyo
Angular JS, A dive to concepts
AngularJS Workshop
AngularJs Workshop SDP December 28th 2014
Introduction to Angularjs : kishan kumar
angularJs Workshop
Angular JS Indtrodution
What Is Angular 2 | Angular 2 Tutorial For Beginners | Angular Training | Edu...
Angular js

More from Manav Prasad (20)

PPTX
Experience with mulesoft
PPTX
Mulesoftconnectors
PPT
Mule and web services
PPTX
Mulesoft cloudhub
PPT
Perl tutorial
PPT
Hibernate presentation
PPT
PPT
Spring introduction
PPT
PPT
The spring framework
PPT
Rest introduction
PPT
Exceptions in java
PPT
PPT
Xml parsers
PPT
PPT
PPT
PPT
PPT
Introduction to html5
PPT
Experience with mulesoft
Mulesoftconnectors
Mule and web services
Mulesoft cloudhub
Perl tutorial
Hibernate presentation
Spring introduction
The spring framework
Rest introduction
Exceptions in java
Xml parsers
Introduction to html5

Recently uploaded (20)

PPTX
UNIT 4 Total Quality Management .pptx
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
Sustainable Sites - Green Building Construction
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
additive manufacturing of ss316l using mig welding
PDF
Well-logging-methods_new................
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
composite construction of structures.pdf
UNIT 4 Total Quality Management .pptx
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
CH1 Production IntroductoryConcepts.pptx
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Embodied AI: Ushering in the Next Era of Intelligent Systems
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
Lecture Notes Electrical Wiring System Components
Sustainable Sites - Green Building Construction
bas. eng. economics group 4 presentation 1.pptx
additive manufacturing of ss316l using mig welding
Well-logging-methods_new................
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
CYBER-CRIMES AND SECURITY A guide to understanding
Model Code of Practice - Construction Work - 21102022 .pdf
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
composite construction of structures.pdf

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