SlideShare a Scribd company logo
1 of 20
Hsiu-Yuan Shan
Looking Back
• Code scattering and tangling(Unobtrusive)
• Dependency management(AMD, module)
• Scope(closure)
• The Pyramid of Doom(promise)
• Testing(Jasmine)
Feature
• MVC/MVVM framework
• Module
• Scope
• Templates and Data Bindings
• Directives
• Dependency Injection
• Testable
http://plnkr.co/edit/0xdJwbiGr8EYqav0DFQr
Declare Controller with function
Model
Directive and Bootstrap
Template and Binding
Anatomy
• Bootstrap
– By using ng-app
– Support manually by angular.bootstrap(element[,
modules]);
• MVC
– View : DOM and template
– Controller : Javascript Function
– Model : Object Properties
• Data Binding
– Updating view({{interpolation}}) whenever
model($scope[properties]) changes and vice versa
Module
• <html ng-app='moduleName'>
• angular.module('moduleName', [dependencie
s])
• Module API
– config/constant/controller/directive/factory/filter/
provider/run/service/value
Scope
• Each Angular application has exactly one root
scope, but may have several child scopes.
• One created with each controller
• Inherited from $rootScope
• $watch
– observe model mutations
• $apply
– propagate any model changes through the system into
the view from outside of the Angular
http://plnkr.co/edit/D8RaIlT9wWDK55HWZSNp
Directives
• ng-init
• ng-bind
• ng-model
• ng-show/ng-hide
• ng-repeat
• ng-switch
Custom Directives
• Consider creating a custom DSL
• Translating the camel case name into snake case
with these special characters :, -, or _
• Options for directive declaration usage
– element
– attribute
– class
– comment
http://plnkr.co/edit/GQkYJMzYyKHJ8Ufmb1nr
http://plnkr.co/edit/MfTAdjUITyR0IniJf51n
Filters
• Format data for display to the user
• {{ expression
[|filter_name[:parameter_value] ... ] }}
• Build-in filter
currency/date/filter/json/limitTo/lowercase/number
/orderBy/uppercase
• Support custom filter
http://plnkr.co/edit/a23sJj4OQpD1BNcuGfJB
Form
• Directive that instantiates FormController
• Types
– text/checkbox/file/password/email/url/numer/range/date
• Status
– $pristine/$dirty/$valid/$invalid/$error
• Validation
– novalidate/required/pattern/minlength/maxlength/min/m
ax/change
• Class
– ng-invalid/ng-valid/ng-pristine/ng-dirty
http://plnkr.co/edit/dE91ImbqV401OfSMoAFx
Dependency Injection
1. moduleName.controller('Controller',['$scope', 'service1',
'service2'],function(($scope,service1,service2){…….});
2. moduleName.controller('Controller',
function(($scope,service1,service2){…….});
3. function($scope,service1,service2){…….}
• Only first is acceptable if you want to minifying your javascript and
it also recommended by official web site
• Third can be acceptable by adding
$Controller.$inject = ['$scope', 'service1', 'service2']
Promise
Service
• service
– get service from instantiation of your function
module.service( 'serviceName', yourFunction);
• factory
– get factory from the value that is returned by invoking your
function
module.factory( 'factoryName', yourFunction);
• provider
– get provider from instantiation of your function and
invoke $get()
module. provider( ' providerName', yourFunction);
http://plnkr.co/edit/fwxmaFBMofiyGd0du1K4
Service Communication
• $http
– low-level implementation of XHR
– support method
GET/HEAD/POST/DELETE/PUT/JSONP
• $resource
– include the angular-resource.js
– angular.module('myModule', ['ngResource']))
– use inject $resource where needed
Service Communication
• $resource
– Default nethod
– Support Custom Method
http://plnkr.co/edit/XVeWmx512HIuYfRYjYdu
Name Method Is Array
get GET
save POST
query GET true
remove DELETE
delete DELETE
Routing
• Used for deep-linking URLs to controllers and views
• Using $routerProvider to point to the correct view
when coupled with the ngView directive at config
phase
• $routeParams
– Current set of route parameters
– /Chapter/:chapterId/Section/:sectionId ==> {chapterId:1,
sectionId:2}
• $locationProvider
– HashBang Mode
– HTML5 Model
http://plnkr.co/edit/RltdXkVrEXRogJVOYbTO
Best Practices
• Script tag on the bottom of page
• Use ng-cloak or ng-bind instead of {{interpolation}} avoid user see{{}}
• Structuring Business Logic
– Controllers
• should not reference DOM
• should have view behavior
– Services
• should not reference DOM
• singleton
• have logic independent of View
• Scope
– threat as read-only in templates and write-only in controllers
– should be the reference of the model
http://www.youtube.com/watch?v=ZhfUv0spHCY&list=TL126yqdm_Yyk
Resource
• http://angularjs.org/
• http://www.youtube.com/user/angularjs
• https://github.com/jmcunningham/AngularJS-
Learning
• https://github.com/angular/angular.js/wiki/JsFidd
le-Examples
• https://gitcafe.com/Angularjs/Angularjs-
Developer-Guide/tree/master
• http://zouyesheng.com/angular.html
• https://www.facebook.com/groups/augularjs.tw/

More Related Content

What's hot

Building and managing java projects with maven part-III
Building and managing java projects with maven part-IIIBuilding and managing java projects with maven part-III
Building and managing java projects with maven part-IIIprinceirfancivil
 
Workshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte IIWorkshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte IIVisual Engineering
 
AngularJS with RequireJS
AngularJS with RequireJSAngularJS with RequireJS
AngularJS with RequireJSJohannes Weber
 
Building and Managing Projects with Maven
Building and Managing Projects with MavenBuilding and Managing Projects with Maven
Building and Managing Projects with MavenKhan625
 
Sails.js Model / ORM introduce
Sails.js Model / ORM introduceSails.js Model / ORM introduce
Sails.js Model / ORM introduce謝 宗穎
 
Angularjs architecture
Angularjs architectureAngularjs architecture
Angularjs architectureMichael He
 
Introduction to VueJS & Vuex
Introduction to VueJS & VuexIntroduction to VueJS & Vuex
Introduction to VueJS & VuexBernd Alter
 
【前端Mvc】之豆瓣说实践
【前端Mvc】之豆瓣说实践【前端Mvc】之豆瓣说实践
【前端Mvc】之豆瓣说实践taobao.com
 
Managing JavaScript Dependencies With RequireJS
Managing JavaScript Dependencies With RequireJSManaging JavaScript Dependencies With RequireJS
Managing JavaScript Dependencies With RequireJSDen Odell
 
Best practice routing in Meteor.js and beyond
Best practice routing in Meteor.js and beyondBest practice routing in Meteor.js and beyond
Best practice routing in Meteor.js and beyondFabian Kromer
 
How to Build SPA with Vue Router 2.0
How to Build SPA with Vue Router 2.0How to Build SPA with Vue Router 2.0
How to Build SPA with Vue Router 2.0Takuya Tejima
 

What's hot (20)

Building and managing java projects with maven part-III
Building and managing java projects with maven part-IIIBuilding and managing java projects with maven part-III
Building and managing java projects with maven part-III
 
Workshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte IIWorkshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte II
 
AngularJS with RequireJS
AngularJS with RequireJSAngularJS with RequireJS
AngularJS with RequireJS
 
Backbone
BackboneBackbone
Backbone
 
Building and Managing Projects with Maven
Building and Managing Projects with MavenBuilding and Managing Projects with Maven
Building and Managing Projects with Maven
 
Expressjs
ExpressjsExpressjs
Expressjs
 
Spring Web MVC
Spring Web MVCSpring Web MVC
Spring Web MVC
 
Sails.js Model / ORM introduce
Sails.js Model / ORM introduceSails.js Model / ORM introduce
Sails.js Model / ORM introduce
 
Angularjs architecture
Angularjs architectureAngularjs architecture
Angularjs architecture
 
Sails js
Sails jsSails js
Sails js
 
Introduction to VueJS & Vuex
Introduction to VueJS & VuexIntroduction to VueJS & Vuex
Introduction to VueJS & Vuex
 
Meteor iron:router
Meteor iron:routerMeteor iron:router
Meteor iron:router
 
AngularJS Basics
AngularJS BasicsAngularJS Basics
AngularJS Basics
 
AngularJS
AngularJSAngularJS
AngularJS
 
Express JS
Express JSExpress JS
Express JS
 
Vuex
VuexVuex
Vuex
 
【前端Mvc】之豆瓣说实践
【前端Mvc】之豆瓣说实践【前端Mvc】之豆瓣说实践
【前端Mvc】之豆瓣说实践
 
Managing JavaScript Dependencies With RequireJS
Managing JavaScript Dependencies With RequireJSManaging JavaScript Dependencies With RequireJS
Managing JavaScript Dependencies With RequireJS
 
Best practice routing in Meteor.js and beyond
Best practice routing in Meteor.js and beyondBest practice routing in Meteor.js and beyond
Best practice routing in Meteor.js and beyond
 
How to Build SPA with Vue Router 2.0
How to Build SPA with Vue Router 2.0How to Build SPA with Vue Router 2.0
How to Build SPA with Vue Router 2.0
 

Viewers also liked

Claude Jospeh Vernet
Claude Jospeh VernetClaude Jospeh Vernet
Claude Jospeh VernetspsuART
 
Why it’s hard to believe in failure
Why it’s hard to believe in failureWhy it’s hard to believe in failure
Why it’s hard to believe in failureSyed M Zeeshan
 
Reasons Social Media is Bad.
Reasons Social Media is Bad.Reasons Social Media is Bad.
Reasons Social Media is Bad.Syed M Zeeshan
 
Introduction of angular js
Introduction of angular jsIntroduction of angular js
Introduction of angular jsTamer Solieman
 
Do not submit acc 422 week 3 wiley plus assignment exercises
Do not submit acc 422 week 3 wiley plus assignment    exercisesDo not submit acc 422 week 3 wiley plus assignment    exercises
Do not submit acc 422 week 3 wiley plus assignment exercisesjefferysbush1
 
Introduction to Angular js
Introduction to Angular jsIntroduction to Angular js
Introduction to Angular jsMustafa Gamal
 
Introduction to Angular js 2.0
Introduction to Angular js 2.0Introduction to Angular js 2.0
Introduction to Angular js 2.0Nagaraju Sangam
 
Angular JS blog tutorial
Angular JS blog tutorialAngular JS blog tutorial
Angular JS blog tutorialClaude Tech
 
Angular js introduction by Tania Gonzales
Angular js introduction by Tania GonzalesAngular js introduction by Tania Gonzales
Angular js introduction by Tania GonzalesThoughtworks
 
Angular js quick start
Angular js quick startAngular js quick start
Angular js quick start정기 김
 
Social media etiquette
Social media etiquette Social media etiquette
Social media etiquette Syed M Zeeshan
 
Valentine with Angular js - Introduction
Valentine with Angular js - IntroductionValentine with Angular js - Introduction
Valentine with Angular js - IntroductionSenthil Kumar
 

Viewers also liked (18)

Claude Jospeh Vernet
Claude Jospeh VernetClaude Jospeh Vernet
Claude Jospeh Vernet
 
Why it’s hard to believe in failure
Why it’s hard to believe in failureWhy it’s hard to believe in failure
Why it’s hard to believe in failure
 
Spanning tree protocol
Spanning tree protocolSpanning tree protocol
Spanning tree protocol
 
Dynamics
Dynamics Dynamics
Dynamics
 
Reasons Social Media is Bad.
Reasons Social Media is Bad.Reasons Social Media is Bad.
Reasons Social Media is Bad.
 
Introduction of angular js
Introduction of angular jsIntroduction of angular js
Introduction of angular js
 
Do not submit acc 422 week 3 wiley plus assignment exercises
Do not submit acc 422 week 3 wiley plus assignment    exercisesDo not submit acc 422 week 3 wiley plus assignment    exercises
Do not submit acc 422 week 3 wiley plus assignment exercises
 
Introduction to Angular js
Introduction to Angular jsIntroduction to Angular js
Introduction to Angular js
 
Introduction to Angular js 2.0
Introduction to Angular js 2.0Introduction to Angular js 2.0
Introduction to Angular js 2.0
 
Angular Seminar-js
Angular Seminar-jsAngular Seminar-js
Angular Seminar-js
 
Angular JS blog tutorial
Angular JS blog tutorialAngular JS blog tutorial
Angular JS blog tutorial
 
Angular js introduction by Tania Gonzales
Angular js introduction by Tania GonzalesAngular js introduction by Tania Gonzales
Angular js introduction by Tania Gonzales
 
Angular js quick start
Angular js quick startAngular js quick start
Angular js quick start
 
Ms office History
Ms office HistoryMs office History
Ms office History
 
Social media etiquette
Social media etiquette Social media etiquette
Social media etiquette
 
Basic of MS Outlook
Basic of MS OutlookBasic of MS Outlook
Basic of MS Outlook
 
Valentine with Angular js - Introduction
Valentine with Angular js - IntroductionValentine with Angular js - Introduction
Valentine with Angular js - Introduction
 
Vertical Axis Wind Turbines
Vertical Axis Wind TurbinesVertical Axis Wind Turbines
Vertical Axis Wind Turbines
 

Similar to Hsiu-Yuan Shan's AngularJS Anatomy

Similar to Hsiu-Yuan Shan's AngularJS Anatomy (20)

AngularJS.part1
AngularJS.part1AngularJS.part1
AngularJS.part1
 
AngularJs Crash Course
AngularJs Crash CourseAngularJs Crash Course
AngularJs Crash Course
 
Front end development with Angular JS
Front end development with Angular JSFront end development with Angular JS
Front end development with Angular JS
 
Angular js
Angular jsAngular js
Angular js
 
Basics of AngularJS
Basics of AngularJSBasics of AngularJS
Basics of AngularJS
 
Angular js-crash-course
Angular js-crash-courseAngular js-crash-course
Angular js-crash-course
 
Angular js
Angular jsAngular js
Angular js
 
The AngularJS way
The AngularJS wayThe AngularJS way
The AngularJS way
 
Angular js 1.0-fundamentals
Angular js 1.0-fundamentalsAngular js 1.0-fundamentals
Angular js 1.0-fundamentals
 
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs Workshop
 
AngularJS Best Practices
AngularJS Best PracticesAngularJS Best Practices
AngularJS Best Practices
 
Angular Js Basics
Angular Js BasicsAngular Js Basics
Angular Js Basics
 
Coffee@DBG - Exploring Angular JS
Coffee@DBG - Exploring Angular JSCoffee@DBG - Exploring Angular JS
Coffee@DBG - Exploring Angular JS
 
Liferay (DXP) 7 Tech Meetup for Developers
Liferay (DXP) 7 Tech Meetup for DevelopersLiferay (DXP) 7 Tech Meetup for Developers
Liferay (DXP) 7 Tech Meetup for Developers
 
AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014
 
JavaScripters Event Oct 22, 2016 · 2:00 PM: Common Mistakes made by Angular D...
JavaScripters Event Oct 22, 2016 · 2:00 PM: Common Mistakes made by Angular D...JavaScripters Event Oct 22, 2016 · 2:00 PM: Common Mistakes made by Angular D...
JavaScripters Event Oct 22, 2016 · 2:00 PM: Common Mistakes made by Angular D...
 
Angular js
Angular jsAngular js
Angular js
 
AngularJs-training
AngularJs-trainingAngularJs-training
AngularJs-training
 
Single page apps_with_cf_and_angular[1]
Single page apps_with_cf_and_angular[1]Single page apps_with_cf_and_angular[1]
Single page apps_with_cf_and_angular[1]
 
Aurelia Meetup Paris
Aurelia Meetup ParisAurelia Meetup Paris
Aurelia Meetup Paris
 

Recently uploaded

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
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
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
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
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
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
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
 
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
 

Recently uploaded (20)

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
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
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
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
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...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
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
 
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...
 

Hsiu-Yuan Shan's AngularJS Anatomy

  • 2. Looking Back • Code scattering and tangling(Unobtrusive) • Dependency management(AMD, module) • Scope(closure) • The Pyramid of Doom(promise) • Testing(Jasmine)
  • 3. Feature • MVC/MVVM framework • Module • Scope • Templates and Data Bindings • Directives • Dependency Injection • Testable
  • 4. http://plnkr.co/edit/0xdJwbiGr8EYqav0DFQr Declare Controller with function Model Directive and Bootstrap Template and Binding
  • 5.
  • 6. Anatomy • Bootstrap – By using ng-app – Support manually by angular.bootstrap(element[, modules]); • MVC – View : DOM and template – Controller : Javascript Function – Model : Object Properties • Data Binding – Updating view({{interpolation}}) whenever model($scope[properties]) changes and vice versa
  • 7. Module • <html ng-app='moduleName'> • angular.module('moduleName', [dependencie s]) • Module API – config/constant/controller/directive/factory/filter/ provider/run/service/value
  • 8. Scope • Each Angular application has exactly one root scope, but may have several child scopes. • One created with each controller • Inherited from $rootScope • $watch – observe model mutations • $apply – propagate any model changes through the system into the view from outside of the Angular http://plnkr.co/edit/D8RaIlT9wWDK55HWZSNp
  • 9. Directives • ng-init • ng-bind • ng-model • ng-show/ng-hide • ng-repeat • ng-switch
  • 10. Custom Directives • Consider creating a custom DSL • Translating the camel case name into snake case with these special characters :, -, or _ • Options for directive declaration usage – element – attribute – class – comment http://plnkr.co/edit/GQkYJMzYyKHJ8Ufmb1nr http://plnkr.co/edit/MfTAdjUITyR0IniJf51n
  • 11. Filters • Format data for display to the user • {{ expression [|filter_name[:parameter_value] ... ] }} • Build-in filter currency/date/filter/json/limitTo/lowercase/number /orderBy/uppercase • Support custom filter http://plnkr.co/edit/a23sJj4OQpD1BNcuGfJB
  • 12. Form • Directive that instantiates FormController • Types – text/checkbox/file/password/email/url/numer/range/date • Status – $pristine/$dirty/$valid/$invalid/$error • Validation – novalidate/required/pattern/minlength/maxlength/min/m ax/change • Class – ng-invalid/ng-valid/ng-pristine/ng-dirty http://plnkr.co/edit/dE91ImbqV401OfSMoAFx
  • 13. Dependency Injection 1. moduleName.controller('Controller',['$scope', 'service1', 'service2'],function(($scope,service1,service2){…….}); 2. moduleName.controller('Controller', function(($scope,service1,service2){…….}); 3. function($scope,service1,service2){…….} • Only first is acceptable if you want to minifying your javascript and it also recommended by official web site • Third can be acceptable by adding $Controller.$inject = ['$scope', 'service1', 'service2']
  • 15. Service • service – get service from instantiation of your function module.service( 'serviceName', yourFunction); • factory – get factory from the value that is returned by invoking your function module.factory( 'factoryName', yourFunction); • provider – get provider from instantiation of your function and invoke $get() module. provider( ' providerName', yourFunction); http://plnkr.co/edit/fwxmaFBMofiyGd0du1K4
  • 16. Service Communication • $http – low-level implementation of XHR – support method GET/HEAD/POST/DELETE/PUT/JSONP • $resource – include the angular-resource.js – angular.module('myModule', ['ngResource'])) – use inject $resource where needed
  • 17. Service Communication • $resource – Default nethod – Support Custom Method http://plnkr.co/edit/XVeWmx512HIuYfRYjYdu Name Method Is Array get GET save POST query GET true remove DELETE delete DELETE
  • 18. Routing • Used for deep-linking URLs to controllers and views • Using $routerProvider to point to the correct view when coupled with the ngView directive at config phase • $routeParams – Current set of route parameters – /Chapter/:chapterId/Section/:sectionId ==> {chapterId:1, sectionId:2} • $locationProvider – HashBang Mode – HTML5 Model http://plnkr.co/edit/RltdXkVrEXRogJVOYbTO
  • 19. Best Practices • Script tag on the bottom of page • Use ng-cloak or ng-bind instead of {{interpolation}} avoid user see{{}} • Structuring Business Logic – Controllers • should not reference DOM • should have view behavior – Services • should not reference DOM • singleton • have logic independent of View • Scope – threat as read-only in templates and write-only in controllers – should be the reference of the model http://www.youtube.com/watch?v=ZhfUv0spHCY&list=TL126yqdm_Yyk
  • 20. Resource • http://angularjs.org/ • http://www.youtube.com/user/angularjs • https://github.com/jmcunningham/AngularJS- Learning • https://github.com/angular/angular.js/wiki/JsFidd le-Examples • https://gitcafe.com/Angularjs/Angularjs- Developer-Guide/tree/master • http://zouyesheng.com/angular.html • https://www.facebook.com/groups/augularjs.tw/