SlideShare a Scribd company logo
Front End Development
with AngularJS
Presented by:
Bipin Upadhyaya
Node package manager
• Node.js Package Management (NPM)
 Package manager for Node.js modules
 Initializes an empty Node.js project with package.json file
npm init
Let’s start bootstrapping
(you no longer have to write the boilerplate)
Client side package manager
npm install -g bower
bower search <query>
bower install <package>#<version>
bower uninstall <package>
bower list
Bower is to the web browser what NPM is to Node.js. It is a
package manager for your front-end development libraries like
jQuery, Bootstrap and so on.
Some commands
(self explanatory)
Automate your frontend workflows
npm install -g grunt-cli npm install -g gulp
Grunt and Gulp make it easy to incorporate best practices and
automate the tedious parts of web development.
Yoman: Web scaffolding tool for
modern app
3 types of tools for improving productivity and satisfaction
when building a web app
npm install -g yo
yo scaffolds out a new application, writing your build configuration ad pulling relevant
build tasks and package manager dependencies that you might need for your build.
Front end development with Angular JS
$ grunt serve
Angular MVC Architecture Pattern
• Layers
• View: Defines visual appearance
• Model: Defines data model of the
app (JS objects)
• Controller: Adds behavior
• Workflow
• User interacts with the view
• Changes the model, call controller
• Controller manipulates the model,
interacts with service
• Angular JS detects model changes
and updates the view
HTML
CSS
Javascript
Controller
ModelView
Server
User
Data Binding Syncing of the data between the Scope and the HTML (two ways)
Scope Context where the model data is stored so that templates and
controllers can access
Directive Allows developer to extend HTML with own elements and
attributes (reusable pieces)
Template HTML with additional markup used to describe what should be
displayed
Compiler Processes the template to generate HTML for the browser
Dependency Injection Fetching and setting up all the functionality needed by a
component
Module A container for all the parts of an application
Angular Concepts and Terminology
Angular Ecosystem
Ref. 1
Automatically bootstrapping
AngularJS
Ref. 1
var demoApp = angular.module(‘AngularApp', []);
What's the Array
for?
var demoApp = angular.module('demoApp',
['helperModule']);
Module that demoApp
depends on
Creating a Module
Module Phases
Config
• happens early while the application
is still being built. Only provider
services and constant services are
ready for dependency injection at
this stage.
RUN
• happens once the module has
loaded all of its services and
dependencies.
var module = angular.module(‘AngularApp', []);
module.config([function() {
alert('I run first');
}]);
module.run([function() {
alert('I run second');
}]);
Module Components and
Dependency Injection
• AngularJS lets you inject services (either from its own module or from
other modules) with the following pattern:
var module = angular.module(‘AngularApp', []);
module.service('serviceA', function() { ... });
module.service('serviceB', function(serviceA) { ... });
Using Directives and Data
Binding
<!DOCTYPE html>
<html ng-app= “AngularApp”>
<head>
<title></title>
</head>
<body>
<div class="container">
Name: <input type="text" ng-model="name" /> {{ name }}
</div>
<script src=“scripts/angular.js"></script>
</body>
</html>
Directive
Directive
Data Binding
Expression
<html data-ng-app="">
...
<div class="container"
data-ng-init="names=['Dave','Napur','Heedy','Shriva']">
<h3>Looping with the ng-repeat Directive</h3>
<ul>
<li data-ng-repeat="name in names">{{ name }}</li>
</ul>
</div>
...
</html>
Iterate through
names
Iterating with the ng-repeat
Directive
Naming Custom Directive
• When defining a directive in JavaScript, the name is in camel case
format:
• When we activate that directive we use a lower case form:
module.directive('myDirective', [function() { ... }]);
<my-directive></my-directive>
<div my-directive></div>
Example Custom Directive
comment directives
must set replace to true
Output in browser
Define the directive
Use it in HMTL
Defining Routes
var demoApp = angular.module(‘AngularApp', ['ngRoute']);
demoApp.config(function ($routeProvider) {
$routeProvider
.when('/',
{
controller: 'SimpleController',
templateUrl:'View1.html'
})
.when('/view2',
{
controller: 'SimpleController',
templateUrl:'View2.html'
})
.otherwise({ redirectTo: '/' });
});
Define Module
Routes
Filters
 Formats the value of an expression for display to the user.
 Filter can be used in view templates, controllers or services &
it is easy to define your own filter.
<ul>
<li ng-repeat="cust in customers | orderBy:'name'">
{{ cust.name | uppercase }}
</li>
</ul> Order customers by
name property
<input type="text" ng-model="nameText" />
<ul>
<li ng-repeat="cust in customers | filter:nameText | orderBy:'name'">
{{ cust.name }} - {{ cust.city }}</li>
</ul>
Filter customers by
model value
var demoApp = angular.module(‘AngularApp', []);
demoApp.controller('SimpleController', function ($scope) {
$scope.customers = [
{ name: 'Dave Jones', city: 'Phoenix' },
{ name: 'Jamie Riley', city: 'Atlanta' },
{ name: 'Heedy Wahlin', city: 'Chandler' },
{ name: 'Thomas Winter', city: 'Seattle' }
];
});
Define a Module
Define a
Controller
Creating a Controller in a
Module
<div class="container" ng-controller="SimpleController">
<h3>Adding a Simple Controller</h3>
<ul>
<li data-ng-repeat="cust in customers">
{{ cust.name }} - {{ cust.city }}
</li>
</ul>
</div>
<script>
function SimpleController($scope) {
$scope.customers = [
{ name: 'Dave Jones', city: 'Phoenix' },
{ name: 'Jamie Riley', city: 'Atlanta' },
{ name: 'Heedy Wahlin', city: 'Chandler' },
{ name: 'Thomas Winter', city: 'Seattle' }
];
}
</script>
Define the
controller to use
Basic controller
$scope injected
dynamically
Access $scope
Creating a View and
Controller
Value
• The value recipe stores a value within an injectable service.
• A value can store any service type: a string, a number, a function, and
object, etc.
• This value of this service can now be injected into any controller, filter,
or service.
//define a module
var myModule = angular.module(‘AngularApp', []);
//define a value
myModule.value('clientId', 'a12345654321x');
//define a controller that injects the value
myModule.controller('myController', ['$scope', 'clientId', function ($scope, clientId) {
$scope.clientId = clientId;
}]);
Service
• The service recipe will generate a singleton of an instantiated object.
//define a service
myModule.service('person', [function() {
this.first = 'John';
this.last = 'Jones';
this.name = function() {
return this.first + ' ' + this.last;
};
}]);
//inject the person service
myModule.controller('myController', ['$scope', 'person', function($scope,
person) {
$scope.name = person.name();
}]);
$http
$q
$timeout
…..
JS Testing
• Angular is designed to be testable (behavior-view separation, pre-
bundled mocks, dependency injection).
• Unit tests (ensure that the JavaScript code in our application is
operating correctly) - Karma Test Runner + Jasmine.
Jasmine describes the test in natural language.
describe ("A simple test", function (){
it("contains a spec with expectations", function(){
expect(true).toEqual(true);
});
});
TestSuite begins with
a call to describe()
TestCase (or spec)
begins with a it
Testcase contains one
or more matchers
Generating components
through yo generates the
necessary skeleton for tests
References
• http://cdn.tsq.me/ebook/AngularJS%20Test%20Driven.pdf
• https://docs.angularjs.org/guide
• https://dzone.com/refcardz/angularjs-essentials

More Related Content

What's hot (20)

Angular Directives
Angular DirectivesAngular Directives
Angular Directives
Malla Reddy University
 
Angular js PPT
Angular js PPTAngular js PPT
Angular js PPT
Imtiyaz Ahmad Khan
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
David Parsons
 
Angular Advanced Routing
Angular Advanced RoutingAngular Advanced Routing
Angular Advanced Routing
Laurent Duveau
 
Angular Pipes Workshop
Angular Pipes WorkshopAngular Pipes Workshop
Angular Pipes Workshop
Nir Kaufman
 
Angular Data Binding
Angular Data BindingAngular Data Binding
Angular Data Binding
Jennifer Estrada
 
Express js
Express jsExpress js
Express js
Manav Prasad
 
Bootstrap 5 ppt
Bootstrap 5 pptBootstrap 5 ppt
Bootstrap 5 ppt
Mallikarjuna G D
 
Angular
AngularAngular
Angular
Lilia Sfaxi
 
Basics of JavaScript
Basics of JavaScriptBasics of JavaScript
Basics of JavaScript
Bala Narayanan
 
Learn react-js
Learn react-jsLearn react-js
Learn react-js
C...L, NESPRESSO, WAFAASSURANCE, SOFRECOM ORANGE
 
Introduction to Angular 2
Introduction to Angular 2Introduction to Angular 2
Introduction to Angular 2
Knoldus Inc.
 
Dom(document object model)
Dom(document object model)Dom(document object model)
Dom(document object model)
Partnered Health
 
Angular Lifecycle Hooks
Angular Lifecycle HooksAngular Lifecycle Hooks
Angular Lifecycle Hooks
Squash Apps Pvt Ltd
 
Fundamental of Node.JS - Internship Presentation - Week7
Fundamental of Node.JS - Internship Presentation - Week7Fundamental of Node.JS - Internship Presentation - Week7
Fundamental of Node.JS - Internship Presentation - Week7
Devang Garach
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
WebStackAcademy
 
Basics of VueJS
Basics of VueJSBasics of VueJS
Basics of VueJS
Squash Apps Pvt Ltd
 
Angular 9
Angular 9 Angular 9
Angular 9
Raja Vishnu
 
Introduction to Angularjs
Introduction to AngularjsIntroduction to Angularjs
Introduction to Angularjs
Manish Shekhawat
 
ReactJS presentation.pptx
ReactJS presentation.pptxReactJS presentation.pptx
ReactJS presentation.pptx
DivyanshGupta922023
 

Similar to Front end development with Angular JS (20)

Basics of AngularJS
Basics of AngularJSBasics of AngularJS
Basics of AngularJS
Filip Janevski
 
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs Workshop
Ran Wahle
 
AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014
Ran Wahle
 
Angular js 1.3 presentation for fed nov 2014
Angular js 1.3 presentation for fed   nov 2014Angular js 1.3 presentation for fed   nov 2014
Angular js 1.3 presentation for fed nov 2014
Sarah Hudson
 
Angular
AngularAngular
Angular
LearningTech
 
Angular
AngularAngular
Angular
LearningTech
 
Angular Presentation
Angular PresentationAngular Presentation
Angular Presentation
Adam Moore
 
Angular.js Primer in Aalto University
Angular.js Primer in Aalto UniversityAngular.js Primer in Aalto University
Angular.js Primer in Aalto University
SC5.io
 
Angular workshop - Full Development Guide
Angular workshop - Full Development GuideAngular workshop - Full Development Guide
Angular workshop - Full Development Guide
Nitin Giri
 
AngularJS in practice
AngularJS in practiceAngularJS in practice
AngularJS in practice
Eugene Fidelin
 
AngularJS
AngularJSAngularJS
AngularJS
LearningTech
 
AngularJS.part1
AngularJS.part1AngularJS.part1
AngularJS.part1
Andrey Kolodnitsky
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get started
Stéphane Bégaudeau
 
AngularJS
AngularJSAngularJS
AngularJS
Srivatsan Krishnamachari
 
Introduction to AngularJs
Introduction to AngularJsIntroduction to AngularJs
Introduction to AngularJs
murtazahaveliwala
 
Workshop 12: AngularJS Parte I
Workshop 12: AngularJS Parte IWorkshop 12: AngularJS Parte I
Workshop 12: AngularJS Parte I
Visual Engineering
 
AngularJs Crash Course
AngularJs Crash CourseAngularJs Crash Course
AngularJs Crash Course
Keith Bloomfield
 
01 startoff angularjs
01 startoff angularjs01 startoff angularjs
01 startoff angularjs
Erhwen Kuo
 
ME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS FundamentalsME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS Fundamentals
Aviran Cohen
 
Learning AngularJS - Complete coverage of AngularJS features and concepts
Learning AngularJS  - Complete coverage of AngularJS features and conceptsLearning AngularJS  - Complete coverage of AngularJS features and concepts
Learning AngularJS - Complete coverage of AngularJS features and concepts
Suresh Patidar
 
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs Workshop
Ran Wahle
 
AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014
Ran Wahle
 
Angular js 1.3 presentation for fed nov 2014
Angular js 1.3 presentation for fed   nov 2014Angular js 1.3 presentation for fed   nov 2014
Angular js 1.3 presentation for fed nov 2014
Sarah Hudson
 
Angular Presentation
Angular PresentationAngular Presentation
Angular Presentation
Adam Moore
 
Angular.js Primer in Aalto University
Angular.js Primer in Aalto UniversityAngular.js Primer in Aalto University
Angular.js Primer in Aalto University
SC5.io
 
Angular workshop - Full Development Guide
Angular workshop - Full Development GuideAngular workshop - Full Development Guide
Angular workshop - Full Development Guide
Nitin Giri
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get started
Stéphane Bégaudeau
 
Workshop 12: AngularJS Parte I
Workshop 12: AngularJS Parte IWorkshop 12: AngularJS Parte I
Workshop 12: AngularJS Parte I
Visual Engineering
 
01 startoff angularjs
01 startoff angularjs01 startoff angularjs
01 startoff angularjs
Erhwen Kuo
 
ME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS FundamentalsME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS Fundamentals
Aviran Cohen
 
Learning AngularJS - Complete coverage of AngularJS features and concepts
Learning AngularJS  - Complete coverage of AngularJS features and conceptsLearning AngularJS  - Complete coverage of AngularJS features and concepts
Learning AngularJS - Complete coverage of AngularJS features and concepts
Suresh Patidar
 
Ad

Recently uploaded (20)

chemistry investigatory project for class 12
chemistry investigatory project for class 12chemistry investigatory project for class 12
chemistry investigatory project for class 12
Susis10
 
Rigor, ethics, wellbeing and resilience in the ICT doctoral journey
Rigor, ethics, wellbeing and resilience in the ICT doctoral journeyRigor, ethics, wellbeing and resilience in the ICT doctoral journey
Rigor, ethics, wellbeing and resilience in the ICT doctoral journey
Yannis
 
Flow Chart Proses Bisnis prosscesss.docx
Flow Chart Proses Bisnis prosscesss.docxFlow Chart Proses Bisnis prosscesss.docx
Flow Chart Proses Bisnis prosscesss.docx
rifka575530
 
operationg systemsdocumentmemorymanagement
operationg systemsdocumentmemorymanagementoperationg systemsdocumentmemorymanagement
operationg systemsdocumentmemorymanagement
SNIGDHAAPPANABHOTLA
 
Airport_Substation_With_Diagrams (2).pptx
Airport_Substation_With_Diagrams (2).pptxAirport_Substation_With_Diagrams (2).pptx
Airport_Substation_With_Diagrams (2).pptx
BibekMedhi2
 
ACEP Magazine Fifth Edition on 5june2025
ACEP Magazine Fifth Edition on 5june2025ACEP Magazine Fifth Edition on 5june2025
ACEP Magazine Fifth Edition on 5june2025
Rahul
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
djiceramil
 
New Microsoft Office Word Documentfrf.docx
New Microsoft Office Word Documentfrf.docxNew Microsoft Office Word Documentfrf.docx
New Microsoft Office Word Documentfrf.docx
misheetasah
 
Universal Human Values and professional ethics Quantum AKTU BVE401
Universal Human Values and professional ethics Quantum AKTU BVE401Universal Human Values and professional ethics Quantum AKTU BVE401
Universal Human Values and professional ethics Quantum AKTU BVE401
Unknown
 
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptxDevelopment of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
aniket862935
 
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdfIrja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus
 
Structure of OS ppt Structure of OsS ppt
Structure of OS ppt Structure of OsS pptStructure of OS ppt Structure of OsS ppt
Structure of OS ppt Structure of OsS ppt
Wahajch
 
IntroSlides-June-GDG-Cloud-Munich community [email protected]
IntroSlides-June-GDG-Cloud-Munich community gathering@Netlight.pdfIntroSlides-June-GDG-Cloud-Munich community gathering@Netlight.pdf
IntroSlides-June-GDG-Cloud-Munich community [email protected]
Luiz Carneiro
 
Semi-Conductor ppt ShubhamSeSemi-Con.pptx
Semi-Conductor ppt ShubhamSeSemi-Con.pptxSemi-Conductor ppt ShubhamSeSemi-Con.pptx
Semi-Conductor ppt ShubhamSeSemi-Con.pptx
studyshubham18
 
First Review PPT gfinal gyft ftu liu yrfut go
First Review PPT gfinal gyft  ftu liu yrfut goFirst Review PPT gfinal gyft  ftu liu yrfut go
First Review PPT gfinal gyft ftu liu yrfut go
Sowndarya6
 
SEW make Brake BE05 – BE30 Brake – Repair Kit
SEW make Brake BE05 – BE30 Brake – Repair KitSEW make Brake BE05 – BE30 Brake – Repair Kit
SEW make Brake BE05 – BE30 Brake – Repair Kit
projectultramechanix
 
Top Cite Articles- International Journal on Soft Computing, Artificial Intell...
Top Cite Articles- International Journal on Soft Computing, Artificial Intell...Top Cite Articles- International Journal on Soft Computing, Artificial Intell...
Top Cite Articles- International Journal on Soft Computing, Artificial Intell...
ijscai
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
djiceramil
 
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Rearchitecturing a 9-year-old legacy Laravel application.pdfRearchitecturing a 9-year-old legacy Laravel application.pdf
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Takumi Amitani
 
WIRELESS COMMUNICATION SECURITY AND IT’S PROTECTION METHODS
WIRELESS COMMUNICATION SECURITY AND IT’S PROTECTION METHODSWIRELESS COMMUNICATION SECURITY AND IT’S PROTECTION METHODS
WIRELESS COMMUNICATION SECURITY AND IT’S PROTECTION METHODS
samueljackson3773
 
chemistry investigatory project for class 12
chemistry investigatory project for class 12chemistry investigatory project for class 12
chemistry investigatory project for class 12
Susis10
 
Rigor, ethics, wellbeing and resilience in the ICT doctoral journey
Rigor, ethics, wellbeing and resilience in the ICT doctoral journeyRigor, ethics, wellbeing and resilience in the ICT doctoral journey
Rigor, ethics, wellbeing and resilience in the ICT doctoral journey
Yannis
 
Flow Chart Proses Bisnis prosscesss.docx
Flow Chart Proses Bisnis prosscesss.docxFlow Chart Proses Bisnis prosscesss.docx
Flow Chart Proses Bisnis prosscesss.docx
rifka575530
 
operationg systemsdocumentmemorymanagement
operationg systemsdocumentmemorymanagementoperationg systemsdocumentmemorymanagement
operationg systemsdocumentmemorymanagement
SNIGDHAAPPANABHOTLA
 
Airport_Substation_With_Diagrams (2).pptx
Airport_Substation_With_Diagrams (2).pptxAirport_Substation_With_Diagrams (2).pptx
Airport_Substation_With_Diagrams (2).pptx
BibekMedhi2
 
ACEP Magazine Fifth Edition on 5june2025
ACEP Magazine Fifth Edition on 5june2025ACEP Magazine Fifth Edition on 5june2025
ACEP Magazine Fifth Edition on 5june2025
Rahul
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
djiceramil
 
New Microsoft Office Word Documentfrf.docx
New Microsoft Office Word Documentfrf.docxNew Microsoft Office Word Documentfrf.docx
New Microsoft Office Word Documentfrf.docx
misheetasah
 
Universal Human Values and professional ethics Quantum AKTU BVE401
Universal Human Values and professional ethics Quantum AKTU BVE401Universal Human Values and professional ethics Quantum AKTU BVE401
Universal Human Values and professional ethics Quantum AKTU BVE401
Unknown
 
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptxDevelopment of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
aniket862935
 
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdfIrja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus
 
Structure of OS ppt Structure of OsS ppt
Structure of OS ppt Structure of OsS pptStructure of OS ppt Structure of OsS ppt
Structure of OS ppt Structure of OsS ppt
Wahajch
 
Semi-Conductor ppt ShubhamSeSemi-Con.pptx
Semi-Conductor ppt ShubhamSeSemi-Con.pptxSemi-Conductor ppt ShubhamSeSemi-Con.pptx
Semi-Conductor ppt ShubhamSeSemi-Con.pptx
studyshubham18
 
First Review PPT gfinal gyft ftu liu yrfut go
First Review PPT gfinal gyft  ftu liu yrfut goFirst Review PPT gfinal gyft  ftu liu yrfut go
First Review PPT gfinal gyft ftu liu yrfut go
Sowndarya6
 
SEW make Brake BE05 – BE30 Brake – Repair Kit
SEW make Brake BE05 – BE30 Brake – Repair KitSEW make Brake BE05 – BE30 Brake – Repair Kit
SEW make Brake BE05 – BE30 Brake – Repair Kit
projectultramechanix
 
Top Cite Articles- International Journal on Soft Computing, Artificial Intell...
Top Cite Articles- International Journal on Soft Computing, Artificial Intell...Top Cite Articles- International Journal on Soft Computing, Artificial Intell...
Top Cite Articles- International Journal on Soft Computing, Artificial Intell...
ijscai
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
djiceramil
 
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Rearchitecturing a 9-year-old legacy Laravel application.pdfRearchitecturing a 9-year-old legacy Laravel application.pdf
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Takumi Amitani
 
WIRELESS COMMUNICATION SECURITY AND IT’S PROTECTION METHODS
WIRELESS COMMUNICATION SECURITY AND IT’S PROTECTION METHODSWIRELESS COMMUNICATION SECURITY AND IT’S PROTECTION METHODS
WIRELESS COMMUNICATION SECURITY AND IT’S PROTECTION METHODS
samueljackson3773
 
Ad

Front end development with Angular JS

  • 1. Front End Development with AngularJS Presented by: Bipin Upadhyaya
  • 2. Node package manager • Node.js Package Management (NPM)  Package manager for Node.js modules  Initializes an empty Node.js project with package.json file npm init
  • 3. Let’s start bootstrapping (you no longer have to write the boilerplate)
  • 4. Client side package manager npm install -g bower bower search <query> bower install <package>#<version> bower uninstall <package> bower list Bower is to the web browser what NPM is to Node.js. It is a package manager for your front-end development libraries like jQuery, Bootstrap and so on. Some commands (self explanatory)
  • 5. Automate your frontend workflows npm install -g grunt-cli npm install -g gulp Grunt and Gulp make it easy to incorporate best practices and automate the tedious parts of web development.
  • 6. Yoman: Web scaffolding tool for modern app 3 types of tools for improving productivity and satisfaction when building a web app npm install -g yo yo scaffolds out a new application, writing your build configuration ad pulling relevant build tasks and package manager dependencies that you might need for your build.
  • 9. Angular MVC Architecture Pattern • Layers • View: Defines visual appearance • Model: Defines data model of the app (JS objects) • Controller: Adds behavior • Workflow • User interacts with the view • Changes the model, call controller • Controller manipulates the model, interacts with service • Angular JS detects model changes and updates the view HTML CSS Javascript Controller ModelView Server User
  • 10. Data Binding Syncing of the data between the Scope and the HTML (two ways) Scope Context where the model data is stored so that templates and controllers can access Directive Allows developer to extend HTML with own elements and attributes (reusable pieces) Template HTML with additional markup used to describe what should be displayed Compiler Processes the template to generate HTML for the browser Dependency Injection Fetching and setting up all the functionality needed by a component Module A container for all the parts of an application Angular Concepts and Terminology
  • 13. var demoApp = angular.module(‘AngularApp', []); What's the Array for? var demoApp = angular.module('demoApp', ['helperModule']); Module that demoApp depends on Creating a Module
  • 14. Module Phases Config • happens early while the application is still being built. Only provider services and constant services are ready for dependency injection at this stage. RUN • happens once the module has loaded all of its services and dependencies. var module = angular.module(‘AngularApp', []); module.config([function() { alert('I run first'); }]); module.run([function() { alert('I run second'); }]);
  • 15. Module Components and Dependency Injection • AngularJS lets you inject services (either from its own module or from other modules) with the following pattern: var module = angular.module(‘AngularApp', []); module.service('serviceA', function() { ... }); module.service('serviceB', function(serviceA) { ... });
  • 16. Using Directives and Data Binding <!DOCTYPE html> <html ng-app= “AngularApp”> <head> <title></title> </head> <body> <div class="container"> Name: <input type="text" ng-model="name" /> {{ name }} </div> <script src=“scripts/angular.js"></script> </body> </html> Directive Directive Data Binding Expression
  • 17. <html data-ng-app=""> ... <div class="container" data-ng-init="names=['Dave','Napur','Heedy','Shriva']"> <h3>Looping with the ng-repeat Directive</h3> <ul> <li data-ng-repeat="name in names">{{ name }}</li> </ul> </div> ... </html> Iterate through names Iterating with the ng-repeat Directive
  • 18. Naming Custom Directive • When defining a directive in JavaScript, the name is in camel case format: • When we activate that directive we use a lower case form: module.directive('myDirective', [function() { ... }]); <my-directive></my-directive> <div my-directive></div>
  • 19. Example Custom Directive comment directives must set replace to true Output in browser Define the directive Use it in HMTL
  • 20. Defining Routes var demoApp = angular.module(‘AngularApp', ['ngRoute']); demoApp.config(function ($routeProvider) { $routeProvider .when('/', { controller: 'SimpleController', templateUrl:'View1.html' }) .when('/view2', { controller: 'SimpleController', templateUrl:'View2.html' }) .otherwise({ redirectTo: '/' }); }); Define Module Routes
  • 21. Filters  Formats the value of an expression for display to the user.  Filter can be used in view templates, controllers or services & it is easy to define your own filter. <ul> <li ng-repeat="cust in customers | orderBy:'name'"> {{ cust.name | uppercase }} </li> </ul> Order customers by name property <input type="text" ng-model="nameText" /> <ul> <li ng-repeat="cust in customers | filter:nameText | orderBy:'name'"> {{ cust.name }} - {{ cust.city }}</li> </ul> Filter customers by model value
  • 22. var demoApp = angular.module(‘AngularApp', []); demoApp.controller('SimpleController', function ($scope) { $scope.customers = [ { name: 'Dave Jones', city: 'Phoenix' }, { name: 'Jamie Riley', city: 'Atlanta' }, { name: 'Heedy Wahlin', city: 'Chandler' }, { name: 'Thomas Winter', city: 'Seattle' } ]; }); Define a Module Define a Controller Creating a Controller in a Module
  • 23. <div class="container" ng-controller="SimpleController"> <h3>Adding a Simple Controller</h3> <ul> <li data-ng-repeat="cust in customers"> {{ cust.name }} - {{ cust.city }} </li> </ul> </div> <script> function SimpleController($scope) { $scope.customers = [ { name: 'Dave Jones', city: 'Phoenix' }, { name: 'Jamie Riley', city: 'Atlanta' }, { name: 'Heedy Wahlin', city: 'Chandler' }, { name: 'Thomas Winter', city: 'Seattle' } ]; } </script> Define the controller to use Basic controller $scope injected dynamically Access $scope Creating a View and Controller
  • 24. Value • The value recipe stores a value within an injectable service. • A value can store any service type: a string, a number, a function, and object, etc. • This value of this service can now be injected into any controller, filter, or service. //define a module var myModule = angular.module(‘AngularApp', []); //define a value myModule.value('clientId', 'a12345654321x'); //define a controller that injects the value myModule.controller('myController', ['$scope', 'clientId', function ($scope, clientId) { $scope.clientId = clientId; }]);
  • 25. Service • The service recipe will generate a singleton of an instantiated object. //define a service myModule.service('person', [function() { this.first = 'John'; this.last = 'Jones'; this.name = function() { return this.first + ' ' + this.last; }; }]); //inject the person service myModule.controller('myController', ['$scope', 'person', function($scope, person) { $scope.name = person.name(); }]); $http $q $timeout …..
  • 26. JS Testing • Angular is designed to be testable (behavior-view separation, pre- bundled mocks, dependency injection). • Unit tests (ensure that the JavaScript code in our application is operating correctly) - Karma Test Runner + Jasmine. Jasmine describes the test in natural language.
  • 27. describe ("A simple test", function (){ it("contains a spec with expectations", function(){ expect(true).toEqual(true); }); }); TestSuite begins with a call to describe() TestCase (or spec) begins with a it Testcase contains one or more matchers
  • 28. Generating components through yo generates the necessary skeleton for tests

Editor's Notes

  • #6: Bascially you create the project (scaffolding, dependency management) 2) Develop (write css, JS), 3) Test 4) Build (Preporcess, minify, optimize images) and finally deploy. There tools makes the build process easy.
  • #13: Manual Bootstrapping angular.element(document).ready(function() { angular.module(‘myApp’, []); angular.bootstrap(document, [‘myApp’]); });
  • #15: When a module runs it has two phases that you can link into. The config phase runs early, before most services, objects, and data are available within the JavaScript. The run phase happens after the services, objects, and data have been defined. There are times when you will want to run some code before those service, objects, and data are defined. We’ll see that in a bit.
  • #21: A container for code for the different parts of your applications. A module is used to define services that are reusable by both the HTML document and other modules: Controller Directive Constant, Value Factory, Provider, Service Filter Best Practice: Divide your code into modules with distinct functionality. Don’t put everything in one module.
  • #26: The value is a pretty basic service that allows you to store any type of data into a service. ** It can be a simple data type, an object, a function, or whatever. ** The value can now be injected into any controller, filter, or service. What if you defined this service in Module X and your in Module Y? Don’t worry about it. Make sure that Module Y includes Module X as a dependency, then inject the service from Module X. ** In the code example you see how we define the service and how we inject it.
  • #27: We write a function as if it were a constructor, using the “this” keyword to set property names and functions that are part of the constructor. When you first inject this service into another controller, filter, or service it will build a singleton from the constructor. Any subsequent injections of the service will get the same singleton.
  • #28: End-to-end tests (ensure that the application as a whole operates as expected) - Protractor E2E test framework for Angular.