SlideShare une entreprise Scribd logo
1  sur  34
Télécharger pour lire hors ligne
Simona Clapan
simona@leanometry.com
Getting Started with
TRADITIONAL PAGE REQUEST
!
Backend
Application!
Database!
Server Response with
Webpage and Assets
Client Side!Server Side!
Javascript
CSS
HTML
Request URL from server
New Request to server
Server Response with
Webpage and Assets
TRADITIONAL WEB APPMODERN PAGE REQUEST
!
Backend
Application!
Database!
Server Response with
JSON Data
Server Response with
Webpage and Assets
Client Side!Server Side!
Javascript
CSS
HTML
Request URL from server
New Request to server
TYPICAL APP ARCHITECTURE
Client
Server
Database
WHAT IS ANGULARJS?
❖ Client-side MVC framework: http://angularjs.org
❖ Problem: Updating page without reload
❖ Solution: Angular.js declarative, 2-way data binding
<html>
<head></head>
<body>
...
</body>
</html>!
!
function Hello(){
alert('Hi there!');
}
!
index.html app.js
❖ ANGULAR JS
➡ download from http://angularjs.org
➡ angular.min.js
❖ TWITTER BOOTSTRAP
➡ download from http://getbootstrap.com
➡ bootstrap.min.css
HOW TO GET STARTED?
TEMPLATE START
<!DOCTYPE html>

<html>

<head>

<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
<script type="text/javascript" src=“js/angular.min.js"></script>
</head>

<body>
</body>

</html>
STARTING TEMPLATE
index.html
DIRECTIVES
❖ Directive: marker on a HTML element (such as an attribute,
element name, comment or CSS class) that tell the angular
compiler to attach a specified behavior to the HTML element.
<html>
<head></head>
<body ng-controller="Hello">
...
</body>
</html>
!
!
index.html
function Hello(){
alert('Hi there!');
}
!
app.js
MODULES
❖ Modules: Apps are structured in modules that can depend on
other modules and can contain controllers, services, directives
and filters
// declare a module
var app =
angular.module("myApp", []);
app.js
module API module name dependencies
index.html
<!—- reference the new module —>
<html ng-app="myApp"></html>
to
bootstrap the module use the directive
ng-app to reference module by name
SAMPLE CODE
index.html
<!DOCTYPE html>
<!—- reference the new module module —->
<html ng-app="myApp">

<head>

<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
<script type="text/javascript" src="js/angular.min.js"></script>
<!--include our new module-->
<script type="text/javascript" src="js/app.js"></script>
</head>

<body>
</body>

</html>
SAMPLE CODE
Expressions
❖ Expressions: JavaScript-like code snippets that are usually
placed in bindings such as {{ expression }}.
index.html
numeric
operation
string
operation
<p> {{"I have "}} {{4 + 6}} dollars </p>
<p> I have 10 dollars </p> //after evaluation
SAMPLE CODE
index.html
<!DOCTYPE html>
<html ng-app="myApp">

<head>

<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
<script type="text/javascript" src="js/angular.min.js"></script>
<script type="text/javascript" src="js/app.js"></script>
</head>

<body>
</body>

</html>
SAMPLE CODE
<p> {{"I have "}} {{4 + 6}} dollars </p>
CONTROLLERS
❖ Controllers: contain the application behavior. Controllers
populate the scope with all the necessary data for the view.
❖ Using proper separation of concerns, controllers should never
contain anything related to the DOM.
app.js
var info = {
firstName: 'John',
lastName:'Smith',
email: 'john@leanometry.com',
phone:'777.922.2321'
};
var app = angular.module('myApp', [ ]);
app.controller('ContactsController',
function(){
!
});
app.js
SAMPLE CODE
app.js
var app = angular.module('myApp', [ ]);
app.controller('ContactsController', function(){
this.contact = info;
});
!
var info = {
firstName: 'John',
lastName:'Smith',
email: 'john@leanometry.com',
phone:'777.922.2321'
};
STORE DATA IN CONTROLLER
SAMPLE CODE
index.html
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
<script type="text/javascript" src="js/angular.min.js"></script>
<script type="text/javascript" src="js/app.js"></script>
</head>
<body>
!
!
!
!
!
!
</body>
</html>
!
WHERE TO ADD ON HTML
<h1>Contact Info</h1>
<div>
<label>First Name:</label><br/>
<label>Last Name:</label><br/>
<label>Email:</label><br/>
<label>Phone Number:</label>
</div>
SAMPLE CODE
index.html
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
<script type="text/javascript" src="js/angular.min.js"></script>
<script type="text/javascript" src="js/app.js"></script>
</head>
<body>
<h1>Contact Info</h1>
<div ng-controller="ContactsController as contacts">
<label>First Name:</label><br/>
<label>Last Name:</label><br/>
<label>Email:</label><br/>
<label>Phone Number:</label>
</div>
</body>
</html>
!
ATTACHING CONTROLLER
directive controller
name
alias
SAMPLE CODE
index.html
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
<script type="text/javascript" src="js/angular.min.js"></script>
<script type="text/javascript" src="js/app.js"></script>
</head>
<body>
<h1>Contact Info</h1>
<div ng-controller="ContactsController as contacts">
<label>First Name: {{contacts.contact.firstName}}</label><br/>
<label>Last Name: {{contacts.contact.lastName}}</label><br/>
<label>Email: {{contacts.contact.email}}</label><br/>
<label>Phone Number: {{contacts.contact.phone}}</label>
</div>
</body>
</html>
!
DISPLAY CONTACT
SCOPE
❖ Scope: an object that refers to the application model. It is an
execution context for expressions.
❖ Scopes are arranged in hierarchical structure which mimic the
DOM structure of the application.
❖ Scopes can watch expressions and propagate events.
SAMPLE CODE
index.html
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
<script type="text/javascript" src="js/angular.min.js"></script>
<script type="text/javascript" src="js/app.js"></script>
</head>
<body>
<h1>Contact Info</h1>
<div ng-controller="ContactsController as contacts">
<label>First Name: {{contacts.contact.firstName}}</label><br/>
<label>Last Name: {{contacts.contact.lastName}}</label><br/>
<label>Email: {{contacts.contact.email}}</label><br/>
<label>Phone Number: {{contacts.contact.phone}}</label>
</div>
{{contacts.contact.phone}} <!—-will not print a value —->
</body>
</html>
!
UNDERSTANDING SCOPE
SAMPLE CODE
<body ng-controller="ContactsController as contacts">
<div >
<h1>New Contact Info</h1>
<label>First Name:</label>
<input type="text" ng-model=“contacts.newContact.firstName”/> <br/>
<label>Last Name:</label>
<input type="text" ng-model="contacts.newContact.lastName"/><br/>
<label>Email:</label>
<input type="text" ng-model="contacts.newContact.email"/><br/>
<label>Phone Number:</label>
<input type="text" ng-model="contacts.newContact.phone"/>
</div>
</body>
index.html
INSERT NEW CONTACT
SAMPLE CODE
<body ng-controller="ContactsController as contacts">
<button type="button">Add Contact</button>
!
<div >
<h1>New Contact Info</h1>
<label>First Name:</label>
<input type="text" ng-model=“contacts.newContact.firstName”/> <br/>
<label>Last Name:</label>
<input type="text" ng-model="contacts.newContact.lastName"/><br/>
<label>Email:</label>
<input type="text" ng-model="contacts.newContact.email"/><br/>
<label>Phone Number:</label>
<input type="text" ng-model="contacts.newContact.phone"/>
</div>
</body> index.html
ADDING A BUTTON
SAMPLE CODE
<body ng-controller="ContactsController as contacts">
<button type="button" ng-click="contacts.addNewContact()">Add Contact</button>
!
<div >
<h1>New Contact Info</h1>
<label>First Name:</label>
<input type="text" ng-model=“contacts.newContact.firstName”/> <br/>
<label>Last Name:</label>
<input type="text" ng-model="contacts.newContact.lastName"/><br/>
<label>Email:</label>
<input type="text" ng-model="contacts.newContact.email"/><br/>
<label>Phone Number:</label>
<input type="text" ng-model=“contacts.newContact.phone"/>
</div>
</body> index.html
ADDING A BUTTON
directive
event name method name parameters
SAMPLE CODE
<body ng-controller"ContactsController as contacts”>
<button type="button" ng-click="contacts.addNewContact()">Add Contact</button>
!
<div ng-show="contacts.isAddNewContact" >
<h1>New Contact Info</h1>
<label>First Name:</label>
<input type="text" ng-model="contacts.newContact.firstName"/> <br/>
<label>Last Name:</label>
<input type="text" ng-model="contacts.newContact.lastName"/><br/>
<label>Email:</label>
<input type="text" ng-model="contacts.newContact.email"/><br/>
<label>Phone Number:</label>
<input type="text" ng-model=“contacts.newContact.phone"/>
</div>
</body> index.html
SET VISIBILITY
SAMPLE CODE
app.js
var app = angular.module('myApp', [ ]);
app.controller('ContactsController', function(){
this.contact = info;
this.newContact ={};
this.isAddNewContact = false;
this.addNewContact = function(){
this.isAddNewContact = true;
}
});
!
var info = {
firstName: 'John',
lastName:'Smith',
email: 'john@leanometry.com',
phone:'777.922.2321'
});
ADD DATA IN CONTROLLER
SAMPLE CODE
<body ng-controller="ContactsController as contacts">
<button type="button" ng-click="contacts.addNewContact()">Add Contact</button>
!
<div ng-show="contacts.isAddNewContact" >
<h1>New Contact Info</h1>
<label>First Name:</label>
<input type="text" ng-model="contacts.newContact.firstName"/>
<label>Last Name:</label>
<input type="text" ng-model="contacts.newContact.lastName"/>
<label>Email:</label>
<input type="text" ng-model="contacts.newContact.email"/>
<label>Phone Number:</label>
<input type="text" ng-model="contacts.newContact.phone"/>
<button type="button" ng-click="contacts.saveContact()">Save</button>
</div>
</body>
index.html
ADD SAVE BUTTON
SAMPLE CODE
app.js
var app = angular.module('myApp', [ ]);
app.controller('ContactsController', function(){
this.contact = info;
this.newContact ={};
this.isAddNewContact = false;
this.addNewContact = function(){
this.isAddNewContact = true;
};
this.saveContact = function(){
this.contact = this.newContact;
this.isAddNewContact = false;
}
});
SAVE IN CONTROLLER
Simona Clapan
simona@leanometry.com
THANK
YOU!
Resources
!
❖ Courses -http://campus.codeschool.com/courses/shaping-up-with-angular-js
❖ AngularJS - http://angularjs.org
SAMPLE CODE
index.html
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
<script type="text/javascript" src="js/angular.min.js"></script>
<script type="text/javascript" src="js/app.js"></script>
</head>
<body ng-controller="ContactsController as contacts">
<button type="button" ng-click="contacts.addNewContact()">Add Contact</button>
<div ng-show="contacts.isAddNewContact" >
<h1>New Contact Info</h1>
<label>First Name:</label>
<input type="text" ng-model="contacts.newContact.firstName"/><br/>
<label>Last Name:</label>
<input type="text" ng-model="contacts.newContact.lastName"/><br/>
<label>Email:</label>
<input type="text" ng-model="contacts.newContact.email"/><br/>
<label>Phone Number:</label>
<input type="text" ng-model="contacts.newContact.phone"/><br/>
<button type="button" ng-click="contacts.saveContact()">Save Contact</button>
</div>
<h1>Contact Info</h1>
<div >
<label>First Name: {{contacts.contact.firstName}}</label>
<label>Last Name: {{contacts.contact.lastName}}</label>
<label>Email: {{contacts.contact.email}}</label>
<label>Phone Number: {{contacts.contact.phone}}</label>
</div>
</body>
</html>
FULL HTML
SAMPLE CODE
app.js
(function(){

var app = angular.module('myApp', [ ]);
app.controller('ContactsController', function(){
this.contact = info;
this.newContact ={};
this.isAddNewContact = false;
this.addNewContact = function( ){
this.isAddNewContact = true;
};
this.saveContact = function(){
this.contact = this.newContact;
this.isAddNewContact = false;
}
});
var info = {
firstName: 'John',
lastName:'Smith',
email: 'john@leanometry.com',
phone:'777.922.2321'
};
!
})();
FULL JS
Angular Components: 1 of 3
❖ Modules: Apps are structured in modules that can depend on other
modules and can contain controllers, services, directives and filters
❖ Controllers contain the application behavior. Controllers populate
the scope with all the necessary data for the view. Using proper
separation of concerns, controllers should never contain anything
related to the DOM.
❖ Scope is used to link the controllers and the views to which they
are binded
Angular Components: 2 of 3
❖ Directives: allows you to extend HTML to answer the needs of web
applications. Directives let you specify how your page should be
structured for the data available in a given scope.
❖ Data Binding: allow defining the binding between the data in the
scope and the content of the views.
❖ Filters: allow modifying the way data is displayed.
❖ Partial Views: used specially in single page applications.
Angular Components: 3 of 3
❖ Services: allow reusing code that should be abstracted from
controller. Services can be injected in controllers or in other
services.
❖ Dependency Injection: retrieves some elements of the application
that should be configured when the module will be loaded
❖ Events: $broadcast and $emit

Contenu connexe

Tendances

Kickstarting Node.js Projects with Yeoman
Kickstarting Node.js Projects with YeomanKickstarting Node.js Projects with Yeoman
Kickstarting Node.js Projects with YeomanPatrick Buergin
 
Single page application
Single page applicationSingle page application
Single page applicationArthur Fung
 
Client Vs. Server Rendering
Client Vs. Server RenderingClient Vs. Server Rendering
Client Vs. Server RenderingDavid Amend
 
Client vs Server Templating: Speed up initial load for SPA with Angular as an...
Client vs Server Templating: Speed up initial load for SPA with Angular as an...Client vs Server Templating: Speed up initial load for SPA with Angular as an...
Client vs Server Templating: Speed up initial load for SPA with Angular as an...David Amend
 
Introduction to mean stack
Introduction to mean stackIntroduction to mean stack
Introduction to mean stackPraveen Gubbala
 
Server rendering-talk
Server rendering-talkServer rendering-talk
Server rendering-talkDaiwei Lu
 
Asp.Net 2.0 Presentation
Asp.Net 2.0 PresentationAsp.Net 2.0 Presentation
Asp.Net 2.0 Presentationsasidhar
 
The Evolution of Airbnb's Frontend
The Evolution of Airbnb's FrontendThe Evolution of Airbnb's Frontend
The Evolution of Airbnb's FrontendSpike Brehm
 
Building great spa’s with angular js, asp.net mvc and webapi
Building great spa’s with angular js, asp.net mvc and webapiBuilding great spa’s with angular js, asp.net mvc and webapi
Building great spa’s with angular js, asp.net mvc and webapiMaurice De Beijer [MVP]
 
Refactoring to a Single Page Application
Refactoring to a Single Page ApplicationRefactoring to a Single Page Application
Refactoring to a Single Page ApplicationCodemotion
 
Magnolia & Angular JS - an Approach for Javascript RIAs Delivered by a CMS
Magnolia & Angular JS - an Approach for Javascript RIAs Delivered by a CMSMagnolia & Angular JS - an Approach for Javascript RIAs Delivered by a CMS
Magnolia & Angular JS - an Approach for Javascript RIAs Delivered by a CMSMagnolia
 
Server and client rendering of single page apps
Server and client rendering of single page appsServer and client rendering of single page apps
Server and client rendering of single page appsThomas Heymann
 

Tendances (20)

Kickstarting Node.js Projects with Yeoman
Kickstarting Node.js Projects with YeomanKickstarting Node.js Projects with Yeoman
Kickstarting Node.js Projects with Yeoman
 
Mean stack
Mean stackMean stack
Mean stack
 
Single page application
Single page applicationSingle page application
Single page application
 
Client Vs. Server Rendering
Client Vs. Server RenderingClient Vs. Server Rendering
Client Vs. Server Rendering
 
Client vs Server Templating: Speed up initial load for SPA with Angular as an...
Client vs Server Templating: Speed up initial load for SPA with Angular as an...Client vs Server Templating: Speed up initial load for SPA with Angular as an...
Client vs Server Templating: Speed up initial load for SPA with Angular as an...
 
Angular 2 vs React
Angular 2 vs ReactAngular 2 vs React
Angular 2 vs React
 
Introduction to mean stack
Introduction to mean stackIntroduction to mean stack
Introduction to mean stack
 
Server rendering-talk
Server rendering-talkServer rendering-talk
Server rendering-talk
 
Codegen2021 blazor mobile
Codegen2021 blazor mobileCodegen2021 blazor mobile
Codegen2021 blazor mobile
 
Asp.Net 2.0 Presentation
Asp.Net 2.0 PresentationAsp.Net 2.0 Presentation
Asp.Net 2.0 Presentation
 
Mean PPT
Mean PPTMean PPT
Mean PPT
 
Walther Ajax4
Walther Ajax4Walther Ajax4
Walther Ajax4
 
Walther Aspnet4
Walther Aspnet4Walther Aspnet4
Walther Aspnet4
 
The Evolution of Airbnb's Frontend
The Evolution of Airbnb's FrontendThe Evolution of Airbnb's Frontend
The Evolution of Airbnb's Frontend
 
Universal React apps in Next.js
Universal React apps in Next.jsUniversal React apps in Next.js
Universal React apps in Next.js
 
Building great spa’s with angular js, asp.net mvc and webapi
Building great spa’s with angular js, asp.net mvc and webapiBuilding great spa’s with angular js, asp.net mvc and webapi
Building great spa’s with angular js, asp.net mvc and webapi
 
Refactoring to a Single Page Application
Refactoring to a Single Page ApplicationRefactoring to a Single Page Application
Refactoring to a Single Page Application
 
Magnolia & Angular JS - an Approach for Javascript RIAs Delivered by a CMS
Magnolia & Angular JS - an Approach for Javascript RIAs Delivered by a CMSMagnolia & Angular JS - an Approach for Javascript RIAs Delivered by a CMS
Magnolia & Angular JS - an Approach for Javascript RIAs Delivered by a CMS
 
Server and client rendering of single page apps
Server and client rendering of single page appsServer and client rendering of single page apps
Server and client rendering of single page apps
 
ReactJS Workflows
ReactJS WorkflowsReactJS Workflows
ReactJS Workflows
 

En vedette

The MEAN stack - SoCalCodeCamp - june 29th 2014
The MEAN stack - SoCalCodeCamp - june 29th 2014The MEAN stack - SoCalCodeCamp - june 29th 2014
The MEAN stack - SoCalCodeCamp - june 29th 2014Simona Clapan
 
Rest with java (jax rs) and jersey and swagger
Rest with java (jax rs) and jersey and swaggerRest with java (jax rs) and jersey and swagger
Rest with java (jax rs) and jersey and swaggerKumaraswamy M
 
Growing from 0 to 100 million users
Growing from 0 to 100 million usersGrowing from 0 to 100 million users
Growing from 0 to 100 million usersKoombea
 
Gettings started with the superheroic JavaScript library AngularJS
Gettings started with the superheroic JavaScript library AngularJSGettings started with the superheroic JavaScript library AngularJS
Gettings started with the superheroic JavaScript library AngularJSArmin Vieweg
 
jDays - Spring Boot under the Hood
jDays - Spring Boot under the HoodjDays - Spring Boot under the Hood
jDays - Spring Boot under the HoodNicolas Fränkel
 
Spring Framework - Spring Security
Spring Framework - Spring SecuritySpring Framework - Spring Security
Spring Framework - Spring SecurityDzmitry Naskou
 
Microservices with Spring Boot
Microservices with Spring BootMicroservices with Spring Boot
Microservices with Spring BootJoshua Long
 
How to build a MVP app as a non-tech founder
How to build a MVP app as a non-tech founderHow to build a MVP app as a non-tech founder
How to build a MVP app as a non-tech founderKoombea
 
3rd Batch Jumpstart Program Introduction 201605
3rd Batch Jumpstart Program Introduction 2016053rd Batch Jumpstart Program Introduction 201605
3rd Batch Jumpstart Program Introduction 201605JumpstartProgram
 
Str8ts Weekly Extreme #38 - Solution
Str8ts Weekly Extreme #38 - SolutionStr8ts Weekly Extreme #38 - Solution
Str8ts Weekly Extreme #38 - SolutionSlowThinker
 
19 December 2012 1ABCT Weekly Newsletter
19 December 2012 1ABCT Weekly Newsletter19 December 2012 1ABCT Weekly Newsletter
19 December 2012 1ABCT Weekly NewsletterNoel Waterman
 
2 May 2012 1HBCT Weekly News Update
2 May 2012 1HBCT Weekly News Update2 May 2012 1HBCT Weekly News Update
2 May 2012 1HBCT Weekly News UpdateNoel Waterman
 
T pryor digital scavenger hunt
T pryor digital scavenger huntT pryor digital scavenger hunt
T pryor digital scavenger hunttpryorp3
 
25 APRIL 2012 1HBCT Weekly News Update
 25 APRIL 2012 1HBCT Weekly News Update 25 APRIL 2012 1HBCT Weekly News Update
25 APRIL 2012 1HBCT Weekly News UpdateNoel Waterman
 
September 2012 Vancouver Real Estate stats package.
September 2012 Vancouver Real Estate stats package.September 2012 Vancouver Real Estate stats package.
September 2012 Vancouver Real Estate stats package.Matt Collinge
 
12 Sept 2012 1ABCT Weekly News Update
12 Sept  2012 1ABCT Weekly News Update12 Sept  2012 1ABCT Weekly News Update
12 Sept 2012 1ABCT Weekly News UpdateNoel Waterman
 
Beware of Phishing Scams
Beware of Phishing ScamsBeware of Phishing Scams
Beware of Phishing ScamsNoel Waterman
 

En vedette (20)

The MEAN stack - SoCalCodeCamp - june 29th 2014
The MEAN stack - SoCalCodeCamp - june 29th 2014The MEAN stack - SoCalCodeCamp - june 29th 2014
The MEAN stack - SoCalCodeCamp - june 29th 2014
 
Rest with java (jax rs) and jersey and swagger
Rest with java (jax rs) and jersey and swaggerRest with java (jax rs) and jersey and swagger
Rest with java (jax rs) and jersey and swagger
 
Growing from 0 to 100 million users
Growing from 0 to 100 million usersGrowing from 0 to 100 million users
Growing from 0 to 100 million users
 
04_Node modules
04_Node modules04_Node modules
04_Node modules
 
Gettings started with the superheroic JavaScript library AngularJS
Gettings started with the superheroic JavaScript library AngularJSGettings started with the superheroic JavaScript library AngularJS
Gettings started with the superheroic JavaScript library AngularJS
 
Spring Boot Tutorial
Spring Boot TutorialSpring Boot Tutorial
Spring Boot Tutorial
 
jDays - Spring Boot under the Hood
jDays - Spring Boot under the HoodjDays - Spring Boot under the Hood
jDays - Spring Boot under the Hood
 
Spring Framework - Spring Security
Spring Framework - Spring SecuritySpring Framework - Spring Security
Spring Framework - Spring Security
 
Microservices with Spring Boot
Microservices with Spring BootMicroservices with Spring Boot
Microservices with Spring Boot
 
How to build a MVP app as a non-tech founder
How to build a MVP app as a non-tech founderHow to build a MVP app as a non-tech founder
How to build a MVP app as a non-tech founder
 
3rd Batch Jumpstart Program Introduction 201605
3rd Batch Jumpstart Program Introduction 2016053rd Batch Jumpstart Program Introduction 201605
3rd Batch Jumpstart Program Introduction 201605
 
Str8ts Weekly Extreme #38 - Solution
Str8ts Weekly Extreme #38 - SolutionStr8ts Weekly Extreme #38 - Solution
Str8ts Weekly Extreme #38 - Solution
 
19 December 2012 1ABCT Weekly Newsletter
19 December 2012 1ABCT Weekly Newsletter19 December 2012 1ABCT Weekly Newsletter
19 December 2012 1ABCT Weekly Newsletter
 
2012 Youth Workshops
2012 Youth Workshops2012 Youth Workshops
2012 Youth Workshops
 
2 May 2012 1HBCT Weekly News Update
2 May 2012 1HBCT Weekly News Update2 May 2012 1HBCT Weekly News Update
2 May 2012 1HBCT Weekly News Update
 
T pryor digital scavenger hunt
T pryor digital scavenger huntT pryor digital scavenger hunt
T pryor digital scavenger hunt
 
25 APRIL 2012 1HBCT Weekly News Update
 25 APRIL 2012 1HBCT Weekly News Update 25 APRIL 2012 1HBCT Weekly News Update
25 APRIL 2012 1HBCT Weekly News Update
 
September 2012 Vancouver Real Estate stats package.
September 2012 Vancouver Real Estate stats package.September 2012 Vancouver Real Estate stats package.
September 2012 Vancouver Real Estate stats package.
 
12 Sept 2012 1ABCT Weekly News Update
12 Sept  2012 1ABCT Weekly News Update12 Sept  2012 1ABCT Weekly News Update
12 Sept 2012 1ABCT Weekly News Update
 
Beware of Phishing Scams
Beware of Phishing ScamsBeware of Phishing Scams
Beware of Phishing Scams
 

Similaire à Introduction to angular js july 6th 2014

Course CodeSchool - Shaping up with Angular.js
Course CodeSchool - Shaping up with Angular.jsCourse CodeSchool - Shaping up with Angular.js
Course CodeSchool - Shaping up with Angular.jsVinícius de Moraes
 
243329387 angular-docs
243329387 angular-docs243329387 angular-docs
243329387 angular-docsAbhi166803
 
Workshop 12: AngularJS Parte I
Workshop 12: AngularJS Parte IWorkshop 12: AngularJS Parte I
Workshop 12: AngularJS Parte IVisual Engineering
 
AngularJS Mobile Warsaw 20-10-2014
AngularJS Mobile Warsaw 20-10-2014AngularJS Mobile Warsaw 20-10-2014
AngularJS Mobile Warsaw 20-10-2014Dariusz Kalbarczyk
 
Desenvolvimento web com Ruby on Rails (parte 2)
Desenvolvimento web com Ruby on Rails (parte 2)Desenvolvimento web com Ruby on Rails (parte 2)
Desenvolvimento web com Ruby on Rails (parte 2)Joao Lucas Santana
 
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
 
Implementation of GUI Framework part3
Implementation of GUI Framework part3Implementation of GUI Framework part3
Implementation of GUI Framework part3masahiroookubo
 
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012crokitta
 
Controller in AngularJS
Controller in AngularJSController in AngularJS
Controller in AngularJSBrajesh Yadav
 
HTML5 New and Improved
HTML5   New and ImprovedHTML5   New and Improved
HTML5 New and ImprovedTimothy Fisher
 
PrimeTime JSF with PrimeFaces - Dec 2014
PrimeTime JSF with PrimeFaces - Dec 2014PrimeTime JSF with PrimeFaces - Dec 2014
PrimeTime JSF with PrimeFaces - Dec 2014cagataycivici
 
Spca2014 hillier 3rd party_javascript_libraries
Spca2014 hillier 3rd party_javascript_librariesSpca2014 hillier 3rd party_javascript_libraries
Spca2014 hillier 3rd party_javascript_librariesNCCOMMS
 

Similaire à Introduction to angular js july 6th 2014 (20)

Angular js
Angular jsAngular js
Angular js
 
Course CodeSchool - Shaping up with Angular.js
Course CodeSchool - Shaping up with Angular.jsCourse CodeSchool - Shaping up with Angular.js
Course CodeSchool - Shaping up with Angular.js
 
243329387 angular-docs
243329387 angular-docs243329387 angular-docs
243329387 angular-docs
 
JS-05-Handlebars.ppt
JS-05-Handlebars.pptJS-05-Handlebars.ppt
JS-05-Handlebars.ppt
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
Workshop 12: AngularJS Parte I
Workshop 12: AngularJS Parte IWorkshop 12: AngularJS Parte I
Workshop 12: AngularJS Parte I
 
AngularJS Mobile Warsaw 20-10-2014
AngularJS Mobile Warsaw 20-10-2014AngularJS Mobile Warsaw 20-10-2014
AngularJS Mobile Warsaw 20-10-2014
 
Desenvolvimento web com Ruby on Rails (parte 2)
Desenvolvimento web com Ruby on Rails (parte 2)Desenvolvimento web com Ruby on Rails (parte 2)
Desenvolvimento web com Ruby on Rails (parte 2)
 
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
 
Angular js
Angular jsAngular js
Angular js
 
Implementation of GUI Framework part3
Implementation of GUI Framework part3Implementation of GUI Framework part3
Implementation of GUI Framework part3
 
Basics of AngularJS
Basics of AngularJSBasics of AngularJS
Basics of AngularJS
 
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
 
Java script
Java scriptJava script
Java script
 
Controller in AngularJS
Controller in AngularJSController in AngularJS
Controller in AngularJS
 
Angular js
Angular jsAngular js
Angular js
 
Let's react - Meetup
Let's react - MeetupLet's react - Meetup
Let's react - Meetup
 
HTML5 New and Improved
HTML5   New and ImprovedHTML5   New and Improved
HTML5 New and Improved
 
PrimeTime JSF with PrimeFaces - Dec 2014
PrimeTime JSF with PrimeFaces - Dec 2014PrimeTime JSF with PrimeFaces - Dec 2014
PrimeTime JSF with PrimeFaces - Dec 2014
 
Spca2014 hillier 3rd party_javascript_libraries
Spca2014 hillier 3rd party_javascript_librariesSpca2014 hillier 3rd party_javascript_libraries
Spca2014 hillier 3rd party_javascript_libraries
 

Dernier

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 

Dernier (20)

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 

Introduction to angular js july 6th 2014

  • 2. TRADITIONAL PAGE REQUEST ! Backend Application! Database! Server Response with Webpage and Assets Client Side!Server Side! Javascript CSS HTML Request URL from server New Request to server Server Response with Webpage and Assets
  • 3. TRADITIONAL WEB APPMODERN PAGE REQUEST ! Backend Application! Database! Server Response with JSON Data Server Response with Webpage and Assets Client Side!Server Side! Javascript CSS HTML Request URL from server New Request to server
  • 5. WHAT IS ANGULARJS? ❖ Client-side MVC framework: http://angularjs.org ❖ Problem: Updating page without reload ❖ Solution: Angular.js declarative, 2-way data binding <html> <head></head> <body> ... </body> </html>! ! function Hello(){ alert('Hi there!'); } ! index.html app.js
  • 6. ❖ ANGULAR JS ➡ download from http://angularjs.org ➡ angular.min.js ❖ TWITTER BOOTSTRAP ➡ download from http://getbootstrap.com ➡ bootstrap.min.css HOW TO GET STARTED?
  • 7. TEMPLATE START <!DOCTYPE html>
 <html>
 <head>
 <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" /> <script type="text/javascript" src=“js/angular.min.js"></script> </head>
 <body> </body>
 </html> STARTING TEMPLATE index.html
  • 8. DIRECTIVES ❖ Directive: marker on a HTML element (such as an attribute, element name, comment or CSS class) that tell the angular compiler to attach a specified behavior to the HTML element. <html> <head></head> <body ng-controller="Hello"> ... </body> </html> ! ! index.html function Hello(){ alert('Hi there!'); } ! app.js
  • 9. MODULES ❖ Modules: Apps are structured in modules that can depend on other modules and can contain controllers, services, directives and filters // declare a module var app = angular.module("myApp", []); app.js module API module name dependencies index.html <!—- reference the new module —> <html ng-app="myApp"></html> to bootstrap the module use the directive ng-app to reference module by name
  • 10. SAMPLE CODE index.html <!DOCTYPE html> <!—- reference the new module module —-> <html ng-app="myApp">
 <head>
 <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" /> <script type="text/javascript" src="js/angular.min.js"></script> <!--include our new module--> <script type="text/javascript" src="js/app.js"></script> </head>
 <body> </body>
 </html> SAMPLE CODE
  • 11. Expressions ❖ Expressions: JavaScript-like code snippets that are usually placed in bindings such as {{ expression }}. index.html numeric operation string operation <p> {{"I have "}} {{4 + 6}} dollars </p> <p> I have 10 dollars </p> //after evaluation
  • 12. SAMPLE CODE index.html <!DOCTYPE html> <html ng-app="myApp">
 <head>
 <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" /> <script type="text/javascript" src="js/angular.min.js"></script> <script type="text/javascript" src="js/app.js"></script> </head>
 <body> </body>
 </html> SAMPLE CODE <p> {{"I have "}} {{4 + 6}} dollars </p>
  • 13. CONTROLLERS ❖ Controllers: contain the application behavior. Controllers populate the scope with all the necessary data for the view. ❖ Using proper separation of concerns, controllers should never contain anything related to the DOM. app.js var info = { firstName: 'John', lastName:'Smith', email: 'john@leanometry.com', phone:'777.922.2321' }; var app = angular.module('myApp', [ ]); app.controller('ContactsController', function(){ ! }); app.js
  • 14. SAMPLE CODE app.js var app = angular.module('myApp', [ ]); app.controller('ContactsController', function(){ this.contact = info; }); ! var info = { firstName: 'John', lastName:'Smith', email: 'john@leanometry.com', phone:'777.922.2321' }; STORE DATA IN CONTROLLER
  • 15. SAMPLE CODE index.html <!DOCTYPE html> <html ng-app="myApp"> <head> <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" /> <script type="text/javascript" src="js/angular.min.js"></script> <script type="text/javascript" src="js/app.js"></script> </head> <body> ! ! ! ! ! ! </body> </html> ! WHERE TO ADD ON HTML <h1>Contact Info</h1> <div> <label>First Name:</label><br/> <label>Last Name:</label><br/> <label>Email:</label><br/> <label>Phone Number:</label> </div>
  • 16. SAMPLE CODE index.html <!DOCTYPE html> <html ng-app="myApp"> <head> <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" /> <script type="text/javascript" src="js/angular.min.js"></script> <script type="text/javascript" src="js/app.js"></script> </head> <body> <h1>Contact Info</h1> <div ng-controller="ContactsController as contacts"> <label>First Name:</label><br/> <label>Last Name:</label><br/> <label>Email:</label><br/> <label>Phone Number:</label> </div> </body> </html> ! ATTACHING CONTROLLER directive controller name alias
  • 17. SAMPLE CODE index.html <!DOCTYPE html> <html ng-app="myApp"> <head> <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" /> <script type="text/javascript" src="js/angular.min.js"></script> <script type="text/javascript" src="js/app.js"></script> </head> <body> <h1>Contact Info</h1> <div ng-controller="ContactsController as contacts"> <label>First Name: {{contacts.contact.firstName}}</label><br/> <label>Last Name: {{contacts.contact.lastName}}</label><br/> <label>Email: {{contacts.contact.email}}</label><br/> <label>Phone Number: {{contacts.contact.phone}}</label> </div> </body> </html> ! DISPLAY CONTACT
  • 18. SCOPE ❖ Scope: an object that refers to the application model. It is an execution context for expressions. ❖ Scopes are arranged in hierarchical structure which mimic the DOM structure of the application. ❖ Scopes can watch expressions and propagate events.
  • 19. SAMPLE CODE index.html <!DOCTYPE html> <html ng-app="myApp"> <head> <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" /> <script type="text/javascript" src="js/angular.min.js"></script> <script type="text/javascript" src="js/app.js"></script> </head> <body> <h1>Contact Info</h1> <div ng-controller="ContactsController as contacts"> <label>First Name: {{contacts.contact.firstName}}</label><br/> <label>Last Name: {{contacts.contact.lastName}}</label><br/> <label>Email: {{contacts.contact.email}}</label><br/> <label>Phone Number: {{contacts.contact.phone}}</label> </div> {{contacts.contact.phone}} <!—-will not print a value —-> </body> </html> ! UNDERSTANDING SCOPE
  • 20. SAMPLE CODE <body ng-controller="ContactsController as contacts"> <div > <h1>New Contact Info</h1> <label>First Name:</label> <input type="text" ng-model=“contacts.newContact.firstName”/> <br/> <label>Last Name:</label> <input type="text" ng-model="contacts.newContact.lastName"/><br/> <label>Email:</label> <input type="text" ng-model="contacts.newContact.email"/><br/> <label>Phone Number:</label> <input type="text" ng-model="contacts.newContact.phone"/> </div> </body> index.html INSERT NEW CONTACT
  • 21. SAMPLE CODE <body ng-controller="ContactsController as contacts"> <button type="button">Add Contact</button> ! <div > <h1>New Contact Info</h1> <label>First Name:</label> <input type="text" ng-model=“contacts.newContact.firstName”/> <br/> <label>Last Name:</label> <input type="text" ng-model="contacts.newContact.lastName"/><br/> <label>Email:</label> <input type="text" ng-model="contacts.newContact.email"/><br/> <label>Phone Number:</label> <input type="text" ng-model="contacts.newContact.phone"/> </div> </body> index.html ADDING A BUTTON
  • 22. SAMPLE CODE <body ng-controller="ContactsController as contacts"> <button type="button" ng-click="contacts.addNewContact()">Add Contact</button> ! <div > <h1>New Contact Info</h1> <label>First Name:</label> <input type="text" ng-model=“contacts.newContact.firstName”/> <br/> <label>Last Name:</label> <input type="text" ng-model="contacts.newContact.lastName"/><br/> <label>Email:</label> <input type="text" ng-model="contacts.newContact.email"/><br/> <label>Phone Number:</label> <input type="text" ng-model=“contacts.newContact.phone"/> </div> </body> index.html ADDING A BUTTON directive event name method name parameters
  • 23. SAMPLE CODE <body ng-controller"ContactsController as contacts”> <button type="button" ng-click="contacts.addNewContact()">Add Contact</button> ! <div ng-show="contacts.isAddNewContact" > <h1>New Contact Info</h1> <label>First Name:</label> <input type="text" ng-model="contacts.newContact.firstName"/> <br/> <label>Last Name:</label> <input type="text" ng-model="contacts.newContact.lastName"/><br/> <label>Email:</label> <input type="text" ng-model="contacts.newContact.email"/><br/> <label>Phone Number:</label> <input type="text" ng-model=“contacts.newContact.phone"/> </div> </body> index.html SET VISIBILITY
  • 24. SAMPLE CODE app.js var app = angular.module('myApp', [ ]); app.controller('ContactsController', function(){ this.contact = info; this.newContact ={}; this.isAddNewContact = false; this.addNewContact = function(){ this.isAddNewContact = true; } }); ! var info = { firstName: 'John', lastName:'Smith', email: 'john@leanometry.com', phone:'777.922.2321' }); ADD DATA IN CONTROLLER
  • 25. SAMPLE CODE <body ng-controller="ContactsController as contacts"> <button type="button" ng-click="contacts.addNewContact()">Add Contact</button> ! <div ng-show="contacts.isAddNewContact" > <h1>New Contact Info</h1> <label>First Name:</label> <input type="text" ng-model="contacts.newContact.firstName"/> <label>Last Name:</label> <input type="text" ng-model="contacts.newContact.lastName"/> <label>Email:</label> <input type="text" ng-model="contacts.newContact.email"/> <label>Phone Number:</label> <input type="text" ng-model="contacts.newContact.phone"/> <button type="button" ng-click="contacts.saveContact()">Save</button> </div> </body> index.html ADD SAVE BUTTON
  • 26. SAMPLE CODE app.js var app = angular.module('myApp', [ ]); app.controller('ContactsController', function(){ this.contact = info; this.newContact ={}; this.isAddNewContact = false; this.addNewContact = function(){ this.isAddNewContact = true; }; this.saveContact = function(){ this.contact = this.newContact; this.isAddNewContact = false; } }); SAVE IN CONTROLLER
  • 30. SAMPLE CODE index.html <!DOCTYPE html> <html ng-app="myApp"> <head> <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" /> <script type="text/javascript" src="js/angular.min.js"></script> <script type="text/javascript" src="js/app.js"></script> </head> <body ng-controller="ContactsController as contacts"> <button type="button" ng-click="contacts.addNewContact()">Add Contact</button> <div ng-show="contacts.isAddNewContact" > <h1>New Contact Info</h1> <label>First Name:</label> <input type="text" ng-model="contacts.newContact.firstName"/><br/> <label>Last Name:</label> <input type="text" ng-model="contacts.newContact.lastName"/><br/> <label>Email:</label> <input type="text" ng-model="contacts.newContact.email"/><br/> <label>Phone Number:</label> <input type="text" ng-model="contacts.newContact.phone"/><br/> <button type="button" ng-click="contacts.saveContact()">Save Contact</button> </div> <h1>Contact Info</h1> <div > <label>First Name: {{contacts.contact.firstName}}</label> <label>Last Name: {{contacts.contact.lastName}}</label> <label>Email: {{contacts.contact.email}}</label> <label>Phone Number: {{contacts.contact.phone}}</label> </div> </body> </html> FULL HTML
  • 31. SAMPLE CODE app.js (function(){
 var app = angular.module('myApp', [ ]); app.controller('ContactsController', function(){ this.contact = info; this.newContact ={}; this.isAddNewContact = false; this.addNewContact = function( ){ this.isAddNewContact = true; }; this.saveContact = function(){ this.contact = this.newContact; this.isAddNewContact = false; } }); var info = { firstName: 'John', lastName:'Smith', email: 'john@leanometry.com', phone:'777.922.2321' }; ! })(); FULL JS
  • 32. Angular Components: 1 of 3 ❖ Modules: Apps are structured in modules that can depend on other modules and can contain controllers, services, directives and filters ❖ Controllers contain the application behavior. Controllers populate the scope with all the necessary data for the view. Using proper separation of concerns, controllers should never contain anything related to the DOM. ❖ Scope is used to link the controllers and the views to which they are binded
  • 33. Angular Components: 2 of 3 ❖ Directives: allows you to extend HTML to answer the needs of web applications. Directives let you specify how your page should be structured for the data available in a given scope. ❖ Data Binding: allow defining the binding between the data in the scope and the content of the views. ❖ Filters: allow modifying the way data is displayed. ❖ Partial Views: used specially in single page applications.
  • 34. Angular Components: 3 of 3 ❖ Services: allow reusing code that should be abstracted from controller. Services can be injected in controllers or in other services. ❖ Dependency Injection: retrieves some elements of the application that should be configured when the module will be loaded ❖ Events: $broadcast and $emit