SlideShare a Scribd company logo
1 of 27
AngularJS
Jason
Agenda
• What is AngularJS
• AngularJS Features
• Directives、Filters and Data Binding
• Views、Controllers and Scope
• Modules and Factories
SPA
• Single Page Application
• In which we have a shell page and we can load multiple views into that.
• The Challenge with SPAs
• DOM Manipulation、Caching、Data Binding…etc.
AngularJS
• AngularJS is one core library.
• AngularJS is a structural framework for dynamic web apps
• AngularJS is a full-featured SPA framework
AngularJS
AngularJs
• Angular takes another approach.
• Data binding, as in {{}}.
• DOM control structures for repeating/hiding DOM fragments.
• Support for forms and form validation.
• Attaching code-behind to DOM elements.
• Grouping of HTML into reusable components.
Directives
• A directive is really a way to teach HTML new tricks.
• At a high level, directives are markers on a DOM element (such as an attribute,
element name, comment or CSS class) that tell AngularJS's HTML compiler ($compile)
to attach a specified behavior to that DOM element or even transform the DOM
element and its children.
Using Directives and DataBinding Syntax
<!DOCTYPE html>
<html ng-app>
<head>
<script src="angular.min.js"></script>
<title></title>
</head>
<body>
Name:<input type=“text” ng-model=“name” /> {{ name}}
<p ng-bind="name"></p>
</body>
</html>
Directive
Directive
Data Binding Expression
Directive
Matching Directives
• Any time you see ng- that is an Angular directive
• The normalization process is as follows:
• Strip 「x-」 and 「data-」 from the front of the element/attributes.
• Convert the「 :」 ,「 -」 , or「 _」 delimited name to camelCase.
• Example
• <input type="text" ng-model="name" />
• <input type="text" data-ng-model="name" />
• <input type="text" ng:model="name" />
• <input type="text" ng_model="name" />
Directives
• ng-app directive
• Use this directive to auto-bootstrap an AngularJS application.
• ng-bind directive
• The ngBind attribute tells Angular to replace the text content of the specified HTML
element with the value of a given expression, and to update the text content when the
value of that expression changes.
• ng-model directive
• The ngModel directive binds an input,select, textarea (or custom form control) to a
property on the scope using NgModelController, which is created and exposed by this
directive.
Angular Expressions
• Angular expressions are JavaScript-like code snippets that are usually
placed in bindings such as {{ expression }}.
• For example, these are valid expressions in Angular:
• 1+2
• a+b
• user.name
• Items[index]
Lterating with the ng-repeat Directive
<div data-ng-init="names=['John Smith', 'John Doe', 'Jane Doe']">
<ul>
<li data-ng-repeat="name in names">
{{name}}
</li>
</ul>
</div>
Using Filters
<input type="text" data-ng-model="nameText" />
<div data-ng-init="names=['John Smith', '1John Doe', 'Jane Doe']">
<ul>
<li data-ng-repeat="name in names | filter:nameText">
{{name | uppercase}}
</li>
</ul>
</div>
Understanding Angular Filters
{{ 99 * 99 | number}}
{{ 9999 + 1 | number:2 }}
{{ 99 * 99 | currency}}
{{ 99 * 99 | currency: 'NT$'}}
{{'Hello World' | uppercase}}
{{'Hello World' | lowercase}}
{{ 1393300831 | date: 'medium'}}
{{ 1393300831 | date: 'yyyy-MM-dd'}}
{{ obj | json}}
Understanding Angular Filters
• Format Conver Data Filter
• currency custom filter
• number limiTo
• date orderBy
• lowercase
• uppercase
• json
View, Controllers and Scope
View Controller$scope
$scope is the "glue"(ViewModel) between a controller and a view
Understanding Controllers
• In Angular, a Controller is a JavaScript constructor function that is used to
augment the Angular Scope
• When a Controller is attached to the DOM via the ng-controller directive, Angular
will instantiate a new Controller object, using the specified Controller's constructor
function.
• A new child scope will be available as an injectable parameter to the Controller's
constructor function as $scope.
Creating aView and Controller
<div class="container" data-ng-controller="SimpleController">
<h3>Adding a Simple Controller</h3>
<input type="text" data-ng-model="name" />
<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>
So now we have two properties in the scope.The ng-model is going to add a property in the scope
called name, and we can actually get to that now in the controller by saying $scope.name
Access $scope
Basic controller
Create a Controller in a Module
Module that demoApp
depends on
var demoApp = angular.module('demoApp', []);
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'}
];
});
Create a Controller in a Module
var demoApp = angular.module('demoApp', []);
demoApp.controller('SimpleController', ['$scope', function(scope){
scope.customers = [
{name : 'Dave Jones', city:'Phoenix'},
{name : 'Jamie Riley', city:'Atlanta'},
{name : 'Heedy Wahlin', city:'Chandler'},
{name : 'Thomas Winter', city:'Seattle'}
];
}]);
Create Multi Controller in a Module
var demoApp = angular.module('demoApp', []);
var controllers = {};
controllers.SimpleController = function($scope) {
……
};
controllers.SimpleController2 = function($scope) {
……
};
demoApp.controller(controllers);
The Role of Factories
var demoApp = angular.module('demoApp', [])
.factory('simpleFactory', function(){
var factory = {};
var customers = [………];
factory.getCustomers = function(){
return customers;
};
return factory;
}).controller('SimpleController', function($scope, simpleFactory)
{
$scope.customers = simpleFactory.getCustomers();
});
Factory injected into
controller at runtime
Create Custom Directive
angular.module('docsSimpleDirective', []).controller('Controller', function($scope) {
$scope.customer = {
name: 'Naomi',
address: '1600 Amphitheatre'
};
}).directive('myCustomer', function() {
return {
restrict: 'A',
template: 'Name: {{customer.name}} Address: {{customer.address}}'
};
});
<div ng-controller="Controller">
<div my-customer></div>
</div>
$inject
• If a function has an $inject property and its value is an array of strings, then
the strings represent names of services to be injected into the function.
var MyController = function(renamed$scope, renamedGreeter) {
...
}
MyController['$inject'] = ['$scope', 'greeter'];
ValueVS. ServiceVS. FactoryVS. Provider
• Value
• module.value('valueName', valueObj);
• Get value from valueObj
• Service
• module.service( 'serviceName', ServiceFunction );
• Get service from 'new ServiceFunction()'.
• Factory
• module.factory( 'factoryName', FactoryFunction );
• Get factory from the value that is returned by invoking the FactoryFunction.
• Provider
• module.provider( 'providerName', ProviderFunction);
• Get provider from new ProviderFunction().$get()
$watch
• $watch(watchExpression, listener, [objectEquality])
• Registers a listener callback to be executed whenever the watchExpression changes
• $watchCollection(watchExpression, listener)
• Shallow watches the properties of an object and fires whenever any of the properties
change
Reference
• AngularJS In 60 Minutes
• http://fastandfluid.com/publicdownloads/AngularJSIn60MinutesIsh_DanWahlin_May2
013.pdf
• AngularJS
• https://angularjs.org/

More Related Content

What's hot

Angular 8
Angular 8 Angular 8
Angular 8 Sunil OS
 
Angular kickstart slideshare
Angular kickstart   slideshareAngular kickstart   slideshare
Angular kickstart slideshareSaleemMalik52
 
Angular Data Binding
Angular Data BindingAngular Data Binding
Angular Data BindingDuy Khanh
 
Introduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectIntroduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectJadson Santos
 
Angular data binding
Angular data binding Angular data binding
Angular data binding Sultan Ahmed
 
How to implement internationalization (i18n) in angular application(multiple ...
How to implement internationalization (i18n) in angular application(multiple ...How to implement internationalization (i18n) in angular application(multiple ...
How to implement internationalization (i18n) in angular application(multiple ...Katy Slemon
 
Sharing Data Between Angular Components
Sharing Data Between Angular ComponentsSharing Data Between Angular Components
Sharing Data Between Angular ComponentsSquash Apps Pvt Ltd
 
Angular 2.0 forms
Angular 2.0 formsAngular 2.0 forms
Angular 2.0 formsEyal Vardi
 
Angular 4 Tutorial | What's New In Angular 4 | Angular Training | Edureka
Angular 4 Tutorial | What's New In Angular 4 | Angular Training | EdurekaAngular 4 Tutorial | What's New In Angular 4 | Angular Training | Edureka
Angular 4 Tutorial | What's New In Angular 4 | Angular Training | EdurekaEdureka!
 
Angular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesAngular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesWebStackAcademy
 
Angular 10 course_content
Angular 10 course_contentAngular 10 course_content
Angular 10 course_contentNAVEENSAGGAM1
 
Intro to vue.js
Intro to vue.jsIntro to vue.js
Intro to vue.jsTechMagic
 
Angular Interview Questions & Answers
Angular Interview Questions & AnswersAngular Interview Questions & Answers
Angular Interview Questions & AnswersRatnala Charan kumar
 

What's hot (20)

Angular 8
Angular 8 Angular 8
Angular 8
 
Angular 14.pptx
Angular 14.pptxAngular 14.pptx
Angular 14.pptx
 
Angular kickstart slideshare
Angular kickstart   slideshareAngular kickstart   slideshare
Angular kickstart slideshare
 
Angular Data Binding
Angular Data BindingAngular Data Binding
Angular Data Binding
 
Angular Data Binding
Angular Data BindingAngular Data Binding
Angular Data Binding
 
Introduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectIntroduction to angular with a simple but complete project
Introduction to angular with a simple but complete project
 
Angular data binding
Angular data binding Angular data binding
Angular data binding
 
Angular
AngularAngular
Angular
 
Angular 11
Angular 11Angular 11
Angular 11
 
How to implement internationalization (i18n) in angular application(multiple ...
How to implement internationalization (i18n) in angular application(multiple ...How to implement internationalization (i18n) in angular application(multiple ...
How to implement internationalization (i18n) in angular application(multiple ...
 
Sharing Data Between Angular Components
Sharing Data Between Angular ComponentsSharing Data Between Angular Components
Sharing Data Between Angular Components
 
Angular
AngularAngular
Angular
 
Angular 2.0 forms
Angular 2.0 formsAngular 2.0 forms
Angular 2.0 forms
 
Angular 4 Tutorial | What's New In Angular 4 | Angular Training | Edureka
Angular 4 Tutorial | What's New In Angular 4 | Angular Training | EdurekaAngular 4 Tutorial | What's New In Angular 4 | Angular Training | Edureka
Angular 4 Tutorial | What's New In Angular 4 | Angular Training | Edureka
 
An Intro into webpack
An Intro into webpackAn Intro into webpack
An Intro into webpack
 
Angular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesAngular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP Services
 
Angular 10 course_content
Angular 10 course_contentAngular 10 course_content
Angular 10 course_content
 
Angular Directives
Angular DirectivesAngular Directives
Angular Directives
 
Intro to vue.js
Intro to vue.jsIntro to vue.js
Intro to vue.js
 
Angular Interview Questions & Answers
Angular Interview Questions & AnswersAngular Interview Questions & Answers
Angular Interview Questions & Answers
 

Viewers also liked

James elastic search
James   elastic searchJames   elastic search
James elastic searchLearningTech
 
Peggy 重新認識java script
Peggy 重新認識java scriptPeggy 重新認識java script
Peggy 重新認識java scriptLearningTech
 
What's new in c# 6.0
What's new in c# 6.0What's new in c# 6.0
What's new in c# 6.0LearningTech
 
20150213 linq pad_tips
20150213 linq pad_tips20150213 linq pad_tips
20150213 linq pad_tipsLearningTech
 
Vic weekly learning_20160325
Vic weekly learning_20160325Vic weekly learning_20160325
Vic weekly learning_20160325LearningTech
 
Html, CSS, Javascript, Jquery, Meteor應用
Html, CSS, Javascript, Jquery, Meteor應用Html, CSS, Javascript, Jquery, Meteor應用
Html, CSS, Javascript, Jquery, Meteor應用LearningTech
 
20141107 node js_eventemitterpattern_anney
20141107 node js_eventemitterpattern_anney20141107 node js_eventemitterpattern_anney
20141107 node js_eventemitterpattern_anneyLearningTech
 
Process control nodejs
Process control nodejsProcess control nodejs
Process control nodejsLearningTech
 
Express Web Application Framework
Express Web Application FrameworkExpress Web Application Framework
Express Web Application FrameworkLearningTech
 
An overview of java script in 2015 (ecma script 6)
An overview of java script in 2015 (ecma script 6)An overview of java script in 2015 (ecma script 6)
An overview of java script in 2015 (ecma script 6)LearningTech
 

Viewers also liked (19)

James elastic search
James   elastic searchJames   elastic search
James elastic search
 
Knockout
KnockoutKnockout
Knockout
 
Ken20150313
Ken20150313Ken20150313
Ken20150313
 
Peggy 重新認識java script
Peggy 重新認識java scriptPeggy 重新認識java script
Peggy 重新認識java script
 
What's new in c# 6.0
What's new in c# 6.0What's new in c# 6.0
What's new in c# 6.0
 
20150515ken
20150515ken20150515ken
20150515ken
 
Ken20150320
Ken20150320Ken20150320
Ken20150320
 
20150213 linq pad_tips
20150213 linq pad_tips20150213 linq pad_tips
20150213 linq pad_tips
 
Angular
AngularAngular
Angular
 
Vic weekly learning_20160325
Vic weekly learning_20160325Vic weekly learning_20160325
Vic weekly learning_20160325
 
Html, CSS, Javascript, Jquery, Meteor應用
Html, CSS, Javascript, Jquery, Meteor應用Html, CSS, Javascript, Jquery, Meteor應用
Html, CSS, Javascript, Jquery, Meteor應用
 
Lodash js
Lodash jsLodash js
Lodash js
 
Semantic ui
Semantic uiSemantic ui
Semantic ui
 
20141107 node js_eventemitterpattern_anney
20141107 node js_eventemitterpattern_anney20141107 node js_eventemitterpattern_anney
20141107 node js_eventemitterpattern_anney
 
SQL 效能調校
SQL 效能調校SQL 效能調校
SQL 效能調校
 
Process control nodejs
Process control nodejsProcess control nodejs
Process control nodejs
 
Express Web Application Framework
Express Web Application FrameworkExpress Web Application Framework
Express Web Application Framework
 
An overview of java script in 2015 (ecma script 6)
An overview of java script in 2015 (ecma script 6)An overview of java script in 2015 (ecma script 6)
An overview of java script in 2015 (ecma script 6)
 
node.js errors
node.js errorsnode.js errors
node.js errors
 

Similar to AngularJS Features and Directives

Angular workshop - Full Development Guide
Angular workshop - Full Development GuideAngular workshop - Full Development Guide
Angular workshop - Full Development GuideNitin Giri
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJSDavid Parsons
 
AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014Ran Wahle
 
AngularJS in 60ish Minutes
AngularJS in 60ish MinutesAngularJS in 60ish Minutes
AngularJS in 60ish MinutesDan Wahlin
 
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 conceptsSuresh Patidar
 
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs WorkshopRan Wahle
 
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 startedStéphane Bégaudeau
 
Coffee@DBG - Exploring Angular JS
Coffee@DBG - Exploring Angular JSCoffee@DBG - Exploring Angular JS
Coffee@DBG - Exploring Angular JSDeepu S Nath
 
Angular Js Get Started - Complete Course
Angular Js Get Started - Complete CourseAngular Js Get Started - Complete Course
Angular Js Get Started - Complete CourseEPAM Systems
 
AngularJS Basics
AngularJS BasicsAngularJS Basics
AngularJS BasicsRavi Mone
 

Similar to AngularJS Features and Directives (20)

AngularJS
AngularJSAngularJS
AngularJS
 
Angular js
Angular jsAngular js
Angular js
 
Basics of AngularJS
Basics of AngularJSBasics of AngularJS
Basics of AngularJS
 
Angular workshop - Full Development Guide
Angular workshop - Full Development GuideAngular workshop - Full Development Guide
Angular workshop - Full Development Guide
 
Angular js
Angular jsAngular js
Angular js
 
AngularJS Workshop
AngularJS WorkshopAngularJS Workshop
AngularJS Workshop
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
AngularJS
AngularJSAngularJS
AngularJS
 
Valentine with AngularJS
Valentine with AngularJSValentine with AngularJS
Valentine with AngularJS
 
AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014
 
AngularJS in 60ish Minutes
AngularJS in 60ish MinutesAngularJS in 60ish Minutes
AngularJS in 60ish Minutes
 
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
 
AngularJS.part1
AngularJS.part1AngularJS.part1
AngularJS.part1
 
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs Workshop
 
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
 
Angular js for Beginnners
Angular js for BeginnnersAngular js for Beginnners
Angular js for Beginnners
 
Coffee@DBG - Exploring Angular JS
Coffee@DBG - Exploring Angular JSCoffee@DBG - Exploring Angular JS
Coffee@DBG - Exploring Angular JS
 
Angular Js Get Started - Complete Course
Angular Js Get Started - Complete CourseAngular Js Get Started - Complete Course
Angular Js Get Started - Complete Course
 
AngularJs Crash Course
AngularJs Crash CourseAngularJs Crash Course
AngularJs Crash Course
 
AngularJS Basics
AngularJS BasicsAngularJS Basics
AngularJS Basics
 

More from LearningTech

More from LearningTech (20)

vim
vimvim
vim
 
PostCss
PostCssPostCss
PostCss
 
ReactJs
ReactJsReactJs
ReactJs
 
Docker
DockerDocker
Docker
 
Expression tree
Expression treeExpression tree
Expression tree
 
flexbox report
flexbox reportflexbox report
flexbox report
 
Vic weekly learning_20160504
Vic weekly learning_20160504Vic weekly learning_20160504
Vic weekly learning_20160504
 
Reflection &amp; activator
Reflection &amp; activatorReflection &amp; activator
Reflection &amp; activator
 
Peggy markdown
Peggy markdownPeggy markdown
Peggy markdown
 
Node child process
Node child processNode child process
Node child process
 
20160415ken.lee
20160415ken.lee20160415ken.lee
20160415ken.lee
 
Peggy elasticsearch應用
Peggy elasticsearch應用Peggy elasticsearch應用
Peggy elasticsearch應用
 
Expression tree
Expression treeExpression tree
Expression tree
 
D3js learning tips
D3js learning tipsD3js learning tips
D3js learning tips
 
git command
git commandgit command
git command
 
Asp.net MVC DI
Asp.net MVC DIAsp.net MVC DI
Asp.net MVC DI
 
Vic weekly learning_20151127
Vic weekly learning_20151127Vic weekly learning_20151127
Vic weekly learning_20151127
 
Mocha.js
Mocha.jsMocha.js
Mocha.js
 
R language
R languageR language
R language
 
20151120 ian cocos2d js
20151120 ian cocos2d js20151120 ian cocos2d js
20151120 ian cocos2d js
 

Recently uploaded

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

AngularJS Features and Directives

  • 2. Agenda • What is AngularJS • AngularJS Features • Directives、Filters and Data Binding • Views、Controllers and Scope • Modules and Factories
  • 3. SPA • Single Page Application • In which we have a shell page and we can load multiple views into that. • The Challenge with SPAs • DOM Manipulation、Caching、Data Binding…etc.
  • 4. AngularJS • AngularJS is one core library. • AngularJS is a structural framework for dynamic web apps • AngularJS is a full-featured SPA framework
  • 6. AngularJs • Angular takes another approach. • Data binding, as in {{}}. • DOM control structures for repeating/hiding DOM fragments. • Support for forms and form validation. • Attaching code-behind to DOM elements. • Grouping of HTML into reusable components.
  • 7. Directives • A directive is really a way to teach HTML new tricks. • At a high level, directives are markers on a DOM element (such as an attribute, element name, comment or CSS class) that tell AngularJS's HTML compiler ($compile) to attach a specified behavior to that DOM element or even transform the DOM element and its children.
  • 8. Using Directives and DataBinding Syntax <!DOCTYPE html> <html ng-app> <head> <script src="angular.min.js"></script> <title></title> </head> <body> Name:<input type=“text” ng-model=“name” /> {{ name}} <p ng-bind="name"></p> </body> </html> Directive Directive Data Binding Expression Directive
  • 9. Matching Directives • Any time you see ng- that is an Angular directive • The normalization process is as follows: • Strip 「x-」 and 「data-」 from the front of the element/attributes. • Convert the「 :」 ,「 -」 , or「 _」 delimited name to camelCase. • Example • <input type="text" ng-model="name" /> • <input type="text" data-ng-model="name" /> • <input type="text" ng:model="name" /> • <input type="text" ng_model="name" />
  • 10. Directives • ng-app directive • Use this directive to auto-bootstrap an AngularJS application. • ng-bind directive • The ngBind attribute tells Angular to replace the text content of the specified HTML element with the value of a given expression, and to update the text content when the value of that expression changes. • ng-model directive • The ngModel directive binds an input,select, textarea (or custom form control) to a property on the scope using NgModelController, which is created and exposed by this directive.
  • 11. Angular Expressions • Angular expressions are JavaScript-like code snippets that are usually placed in bindings such as {{ expression }}. • For example, these are valid expressions in Angular: • 1+2 • a+b • user.name • Items[index]
  • 12. Lterating with the ng-repeat Directive <div data-ng-init="names=['John Smith', 'John Doe', 'Jane Doe']"> <ul> <li data-ng-repeat="name in names"> {{name}} </li> </ul> </div>
  • 13. Using Filters <input type="text" data-ng-model="nameText" /> <div data-ng-init="names=['John Smith', '1John Doe', 'Jane Doe']"> <ul> <li data-ng-repeat="name in names | filter:nameText"> {{name | uppercase}} </li> </ul> </div>
  • 14. Understanding Angular Filters {{ 99 * 99 | number}} {{ 9999 + 1 | number:2 }} {{ 99 * 99 | currency}} {{ 99 * 99 | currency: 'NT$'}} {{'Hello World' | uppercase}} {{'Hello World' | lowercase}} {{ 1393300831 | date: 'medium'}} {{ 1393300831 | date: 'yyyy-MM-dd'}} {{ obj | json}}
  • 15. Understanding Angular Filters • Format Conver Data Filter • currency custom filter • number limiTo • date orderBy • lowercase • uppercase • json
  • 16. View, Controllers and Scope View Controller$scope $scope is the "glue"(ViewModel) between a controller and a view
  • 17. Understanding Controllers • In Angular, a Controller is a JavaScript constructor function that is used to augment the Angular Scope • When a Controller is attached to the DOM via the ng-controller directive, Angular will instantiate a new Controller object, using the specified Controller's constructor function. • A new child scope will be available as an injectable parameter to the Controller's constructor function as $scope.
  • 18. Creating aView and Controller <div class="container" data-ng-controller="SimpleController"> <h3>Adding a Simple Controller</h3> <input type="text" data-ng-model="name" /> <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> So now we have two properties in the scope.The ng-model is going to add a property in the scope called name, and we can actually get to that now in the controller by saying $scope.name Access $scope Basic controller
  • 19. Create a Controller in a Module Module that demoApp depends on var demoApp = angular.module('demoApp', []); 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'} ]; });
  • 20. Create a Controller in a Module var demoApp = angular.module('demoApp', []); demoApp.controller('SimpleController', ['$scope', function(scope){ scope.customers = [ {name : 'Dave Jones', city:'Phoenix'}, {name : 'Jamie Riley', city:'Atlanta'}, {name : 'Heedy Wahlin', city:'Chandler'}, {name : 'Thomas Winter', city:'Seattle'} ]; }]);
  • 21. Create Multi Controller in a Module var demoApp = angular.module('demoApp', []); var controllers = {}; controllers.SimpleController = function($scope) { …… }; controllers.SimpleController2 = function($scope) { …… }; demoApp.controller(controllers);
  • 22. The Role of Factories var demoApp = angular.module('demoApp', []) .factory('simpleFactory', function(){ var factory = {}; var customers = [………]; factory.getCustomers = function(){ return customers; }; return factory; }).controller('SimpleController', function($scope, simpleFactory) { $scope.customers = simpleFactory.getCustomers(); }); Factory injected into controller at runtime
  • 23. Create Custom Directive angular.module('docsSimpleDirective', []).controller('Controller', function($scope) { $scope.customer = { name: 'Naomi', address: '1600 Amphitheatre' }; }).directive('myCustomer', function() { return { restrict: 'A', template: 'Name: {{customer.name}} Address: {{customer.address}}' }; }); <div ng-controller="Controller"> <div my-customer></div> </div>
  • 24. $inject • If a function has an $inject property and its value is an array of strings, then the strings represent names of services to be injected into the function. var MyController = function(renamed$scope, renamedGreeter) { ... } MyController['$inject'] = ['$scope', 'greeter'];
  • 25. ValueVS. ServiceVS. FactoryVS. Provider • Value • module.value('valueName', valueObj); • Get value from valueObj • Service • module.service( 'serviceName', ServiceFunction ); • Get service from 'new ServiceFunction()'. • Factory • module.factory( 'factoryName', FactoryFunction ); • Get factory from the value that is returned by invoking the FactoryFunction. • Provider • module.provider( 'providerName', ProviderFunction); • Get provider from new ProviderFunction().$get()
  • 26. $watch • $watch(watchExpression, listener, [objectEquality]) • Registers a listener callback to be executed whenever the watchExpression changes • $watchCollection(watchExpression, listener) • Shallow watches the properties of an object and fires whenever any of the properties change
  • 27. Reference • AngularJS In 60 Minutes • http://fastandfluid.com/publicdownloads/AngularJSIn60MinutesIsh_DanWahlin_May2 013.pdf • AngularJS • https://angularjs.org/

Editor's Notes

  1. minify http://jsbin.com/musiqo/edit?html,js,output
  2. http://jsbin.com/lazila/edit
  3. http://jsbin.com/fusefepama/edit http://bennadel.github.io/JavaScript-Demos/demos/watch-vs-watch-collection/