SlideShare uma empresa Scribd logo
1 de 35
Baixar para ler offline
Single Page 
Applications 
李濬志 Jeremy Lee 
@junzhli
“A Single Page Application is a web app that fits on a single 
page with a goal of providing a more fluid user experience” 
from wikipedia
Web Apps not Web Sites
Web Apps 
• Like desktop applications (Word, Photoshop, Skype) 
• Dynamic and ever-changing 
• Rely on you to interact with them 
• Contributing content. (Facebook, Youtube, Twitter) 
• Gathering data from other sources and presenting it to you 
• Always use databases (PHP, Ruby, Python, framework Rails)
Characteristics 
• 如同應⽤用程式操作特性 
• URL hash 
• 更豐富的互動界⾯面 
• 資料動態載⼊入 
• 允許離線使⽤用 
• 先載⼊入必要檔案即可 
• …
具備離線能⼒力的 SPA
同時具備離線與線上同步能⼒力的 SPA
SPA Benefit 
• 效能提升 
• 更少的資料傳輸 
• 更多回應放到 Client 處理 
• 分散式載⼊入 (Load distribution) 
• 快取 (Cache) 
• 跨平台 
• 程式碼更易維護 
• 響應式網⾴頁設計 (Responsive Web Design)
技術層⾯面 
• XML, JSON and AJAX 
• HTML DOM 
• CSS 
• JavaScript Frameworks 
• HTML5 WebSockets 
• HTML5 Web Storage
Client-side Javascript MV* (MVVM, MVC)
Feature Angular Backbone Ember 
Observables V V V 
Routing V V V 
View bindings V V 
Two way bindings V V 
Partial views V V 
Filtered list views V V
Learning curve and documentation 
• Backbone 
• Ember 
• Angular
Size 
Angular Backbone Ember 
80k 18k 141k 
Size with dependencies 
Backbone needs at least Underscore and Zepto 
Ember needs jQuery and Handlebars 
61K 
269K
http://todomvc.com/
Single Page Application with AngularJS 
• Open-source web application framework 
• model–view–controller (MVC) capability 
• Two-way Data Binding
Controller 
• 負責將 ViewModel 與 View 結合產⽣生 UI 
• ⼀一個網⾴頁裡可以有多個 Controller 負責不同元素 
的 Binding
Scope 
• 資料繫結的對象
Templete 
• 在 HTML 中預先定義好的 Angular 特殊元素 
• Directive, Markup, Filter, Form controls
Directive 
• 賦予 Attribute 或 Element 的相關 DOM 元素額外功能 
• like ngBind, ngModel, and ngView 
• 可⾃自定義 Directive
Filter 
• 應⽤用於 Directive,對繫結的資料進⾏行後置處理 
• {{ expression | filter1 | filter2 | ... }} 
• {{ 1234 | number:2 }}
Service 
• 跨 Controller 的功能邏輯 
• 內部服務 (Internal Service) 
$resource service
Router 
• $route service : $routeProvider 
• 瀏覽器導覽按鈕解決⽅方案 
• Bookmarkable
Hello World ! 
Demo 1 
• Angular module 存取範圍宣告 : ng-app 
• Markup : {{sometext}} 
• ng-bind=“sometext” 
• Directive : ng-init, ng-show, ng-hide 
• Filter : {{ sometext | uppercase }}
Todo List part1 
Demo 2 
• angular.module('Todo', []) 
• angular.module(‘Todo’, []).controller(‘todoController’, …) 
• View 與 model 橋樑 : $scope 
• 與外部 View 直接存取 : $scope.todos 
• $scope.addTodo = function(){ … }
Two-way data binding
Todo List part2 
Demo 2 
• $scope.todos.push({'title':$scope.newTodo, ‘done':false}) 
• ng-controller=“todoController” 
• ng-repeat="todo in todos” 
• ng-disabled=“doWhat.$invaild" 
• ng-submit=“addTodo()" 
• ng-class=“{'done':todo.done}"
Routing 
Demo 3 
• <a href=“#One"> 
• <div ng-view></div> 
• sampleApp.config([‘$routeProvider’, …]) 
• sampleApp.controller(‘OneController' …)
Routing 
Demo 3
Photo Gallery 
Demo 4 
• angular.module(‘photoApp’).factory('photoSearchService', …) 
• var service = {}; 
• service.findPhotos = function(keyword, callback) { … }
Dependency Injection
Reference 
• http://viralpatel.net/blogs/angularjs-routing-and-views-tutorial-with-example/ 
• http://blog.miniasp.com/post/2013/04/24/Front-end-Engineering-Fineart-An-Introduction-to-AngularJS.aspx 
• http://www.dotnet-tricks.com/Tutorial/designpatterns/2FMM060314-Understanding-MVC,-MVP-and-MVVM-Design- 
Patterns.html 
• http://blogs.bluepi.in/2014/08/04/why-single-page-application/ 
• http://www.adobe.com/devnet/html5/articles/getting-started-with-angularjs.html 
• http://plexusweb.com/2013/04/web-site-vs-web-application-whats-the-difference/ 
• http://en.wikipedia.org/wiki/Single-page_application 
• http://codepen.io/Russbrown/pen/IgBuh 
• http://blog.codeschool.com/post/85819292538/angular-backbone-or-ember-which-is-best-for-your
“Thanks”

Mais conteúdo relacionado

Mais procurados

Building SharePoint Single Page Applications Using AngularJS
Building SharePoint Single Page Applications Using AngularJSBuilding SharePoint Single Page Applications Using AngularJS
Building SharePoint Single Page Applications Using AngularJS
SharePointInstitute
 

Mais procurados (20)

sell idea
sell ideasell idea
sell idea
 
Azure Cloud Services
Azure Cloud ServicesAzure Cloud Services
Azure Cloud Services
 
Express yourself
Express yourselfExpress yourself
Express yourself
 
Дмитрий Тежельников «Разработка вэб-решений с использованием Asp.NET.Core и ...
Дмитрий Тежельников  «Разработка вэб-решений с использованием Asp.NET.Core и ...Дмитрий Тежельников  «Разработка вэб-решений с использованием Asp.NET.Core и ...
Дмитрий Тежельников «Разработка вэб-решений с использованием Asp.NET.Core и ...
 
Node ts1
Node ts1Node ts1
Node ts1
 
Ajax
AjaxAjax
Ajax
 
WordPress Workflows
WordPress WorkflowsWordPress Workflows
WordPress Workflows
 
Enterprise Portal 2.0
Enterprise Portal 2.0Enterprise Portal 2.0
Enterprise Portal 2.0
 
MSDN Sessions 032817 - Azure Functions
MSDN Sessions 032817 - Azure FunctionsMSDN Sessions 032817 - Azure Functions
MSDN Sessions 032817 - Azure Functions
 
Asp.net
Asp.netAsp.net
Asp.net
 
Dotnet- An overview of ASP.NET & ADO.NET- Mazenet solution
Dotnet- An overview of ASP.NET & ADO.NET- Mazenet solutionDotnet- An overview of ASP.NET & ADO.NET- Mazenet solution
Dotnet- An overview of ASP.NET & ADO.NET- Mazenet solution
 
Blazor certification training - Dot Net Tricks
Blazor certification training - Dot Net TricksBlazor certification training - Dot Net Tricks
Blazor certification training - Dot Net Tricks
 
Building SharePoint Single Page Applications Using AngularJS
Building SharePoint Single Page Applications Using AngularJSBuilding SharePoint Single Page Applications Using AngularJS
Building SharePoint Single Page Applications Using AngularJS
 
Rest assured
Rest assuredRest assured
Rest assured
 
Full stack devlopment using django main ppt
Full stack devlopment using django main pptFull stack devlopment using django main ppt
Full stack devlopment using django main ppt
 
Scaling Wordpress
Scaling WordpressScaling Wordpress
Scaling Wordpress
 
APIdays San Francisco, 06/22/2013
APIdays San Francisco, 06/22/2013APIdays San Francisco, 06/22/2013
APIdays San Francisco, 06/22/2013
 
Angular JS and Magento
Angular JS and MagentoAngular JS and Magento
Angular JS and Magento
 
Building Modern Web Applications with ASP.NET5
Building Modern Web Applications with ASP.NET5Building Modern Web Applications with ASP.NET5
Building Modern Web Applications with ASP.NET5
 
Spicing up SharePoint web parts
Spicing up SharePoint web partsSpicing up SharePoint web parts
Spicing up SharePoint web parts
 

Destaque

Intro to SPA using JavaScript & ASP.NET
Intro to SPA using JavaScript & ASP.NETIntro to SPA using JavaScript & ASP.NET
Intro to SPA using JavaScript & ASP.NET
Alan Hecht
 
Ajax Introduction Presentation
Ajax   Introduction   PresentationAjax   Introduction   Presentation
Ajax Introduction Presentation
thinkphp
 
Single-Page Web Application Architecture
Single-Page Web Application ArchitectureSingle-Page Web Application Architecture
Single-Page Web Application Architecture
Eray Arslan
 
An Introduction to Ajax Programming
An Introduction to Ajax ProgrammingAn Introduction to Ajax Programming
An Introduction to Ajax Programming
hchen1
 

Destaque (20)

Intro to SPA using JavaScript & ASP.NET
Intro to SPA using JavaScript & ASP.NETIntro to SPA using JavaScript & ASP.NET
Intro to SPA using JavaScript & ASP.NET
 
WebApp / SPA @ AllFacebook Developer Conference
WebApp / SPA @ AllFacebook Developer ConferenceWebApp / SPA @ AllFacebook Developer Conference
WebApp / SPA @ AllFacebook Developer Conference
 
Writing SPA in 2017
Writing SPA in 2017Writing SPA in 2017
Writing SPA in 2017
 
Building Applications Using Ajax
Building Applications Using AjaxBuilding Applications Using Ajax
Building Applications Using Ajax
 
Webinar on Angular JS titled 'Develop Responsive Single Page Application'
Webinar on Angular JS titled 'Develop Responsive Single Page Application'Webinar on Angular JS titled 'Develop Responsive Single Page Application'
Webinar on Angular JS titled 'Develop Responsive Single Page Application'
 
Ajax presentation
Ajax presentationAjax presentation
Ajax presentation
 
Ajax Introduction Presentation
Ajax   Introduction   PresentationAjax   Introduction   Presentation
Ajax Introduction Presentation
 
single page application
single page applicationsingle page application
single page application
 
Angular 2 with TypeScript
Angular 2 with TypeScriptAngular 2 with TypeScript
Angular 2 with TypeScript
 
Single-Page Web Application Architecture
Single-Page Web Application ArchitectureSingle-Page Web Application Architecture
Single-Page Web Application Architecture
 
Rits Brown Bag - TypeScript
Rits Brown Bag - TypeScriptRits Brown Bag - TypeScript
Rits Brown Bag - TypeScript
 
The Tale of 2 CLIs - Ember-cli and Angular-cli
The Tale of 2 CLIs - Ember-cli and Angular-cliThe Tale of 2 CLIs - Ember-cli and Angular-cli
The Tale of 2 CLIs - Ember-cli and Angular-cli
 
Angular 2 + TypeScript = true. Let's Play!
Angular 2 + TypeScript = true. Let's Play!Angular 2 + TypeScript = true. Let's Play!
Angular 2 + TypeScript = true. Let's Play!
 
Using Angular-CLI to Deploy an Angular 2 App Using Firebase in 30 Minutes
Using Angular-CLI to Deploy an Angular 2 App Using Firebase in 30 MinutesUsing Angular-CLI to Deploy an Angular 2 App Using Firebase in 30 Minutes
Using Angular-CLI to Deploy an Angular 2 App Using Firebase in 30 Minutes
 
Angular 2 with TypeScript
Angular 2 with TypeScriptAngular 2 with TypeScript
Angular 2 with TypeScript
 
Creating an Angular 2 Angular CLI app in 15 Minutes Using MaterializeCSS & Fi...
Creating an Angular 2 Angular CLI app in 15 Minutes Using MaterializeCSS & Fi...Creating an Angular 2 Angular CLI app in 15 Minutes Using MaterializeCSS & Fi...
Creating an Angular 2 Angular CLI app in 15 Minutes Using MaterializeCSS & Fi...
 
An Introduction to Ajax Programming
An Introduction to Ajax ProgrammingAn Introduction to Ajax Programming
An Introduction to Ajax Programming
 
Angular 1.x vs 2 - In code level
Angular 1.x vs 2 - In code levelAngular 1.x vs 2 - In code level
Angular 1.x vs 2 - In code level
 
Getting started with Angular CLI
Getting started with Angular CLIGetting started with Angular CLI
Getting started with Angular CLI
 
Single Page Application presentation
Single Page Application presentationSingle Page Application presentation
Single Page Application presentation
 

Semelhante a Single page application

01/2009 - Portral development with liferay
01/2009 - Portral development with liferay01/2009 - Portral development with liferay
01/2009 - Portral development with liferay
daveayan
 
RES Software Online Seminar 10 mei 2011
RES Software Online Seminar 10 mei 2011RES Software Online Seminar 10 mei 2011
RES Software Online Seminar 10 mei 2011
RES Software Nederland
 
Putting the "Share" and "Point" back in SharePoint 2013
Putting the "Share" and "Point" back in SharePoint 2013Putting the "Share" and "Point" back in SharePoint 2013
Putting the "Share" and "Point" back in SharePoint 2013
C/D/H Technology Consultants
 
Oracle - Document Life - 6apr2012
Oracle - Document Life - 6apr2012Oracle - Document Life - 6apr2012
Oracle - Document Life - 6apr2012
Agora Group
 

Semelhante a Single page application (20)

First Look at Azure Logic Apps (BAUG)
First Look at Azure Logic Apps (BAUG)First Look at Azure Logic Apps (BAUG)
First Look at Azure Logic Apps (BAUG)
 
Oracle web center
Oracle web centerOracle web center
Oracle web center
 
Integrated Services for Web Applications
Integrated Services for Web ApplicationsIntegrated Services for Web Applications
Integrated Services for Web Applications
 
DotNetNuke
DotNetNukeDotNetNuke
DotNetNuke
 
01/2009 - Portral development with liferay
01/2009 - Portral development with liferay01/2009 - Portral development with liferay
01/2009 - Portral development with liferay
 
Jaspersoft Reporting v5
Jaspersoft Reporting v5Jaspersoft Reporting v5
Jaspersoft Reporting v5
 
Service-oriented architecture
Service-oriented architectureService-oriented architecture
Service-oriented architecture
 
What's New in Microsoft Dynamics CRM 2011
What's New in Microsoft Dynamics CRM 2011What's New in Microsoft Dynamics CRM 2011
What's New in Microsoft Dynamics CRM 2011
 
Lessons Learned from Real-World Deployments of Java EE 7 at JavaOne 2014
Lessons Learned from Real-World Deployments of Java EE 7 at JavaOne 2014Lessons Learned from Real-World Deployments of Java EE 7 at JavaOne 2014
Lessons Learned from Real-World Deployments of Java EE 7 at JavaOne 2014
 
Enterprise Blockchain & Data Sovereignty. Carlo Ferrarini, IBM
Enterprise Blockchain & Data Sovereignty. Carlo Ferrarini, IBMEnterprise Blockchain & Data Sovereignty. Carlo Ferrarini, IBM
Enterprise Blockchain & Data Sovereignty. Carlo Ferrarini, IBM
 
How to grow your own Microservice?
How to grow your own Microservice?How to grow your own Microservice?
How to grow your own Microservice?
 
Sim-webcast-part1-1aa
Sim-webcast-part1-1aaSim-webcast-part1-1aa
Sim-webcast-part1-1aa
 
RES Software Online Seminar 10 mei 2011
RES Software Online Seminar 10 mei 2011RES Software Online Seminar 10 mei 2011
RES Software Online Seminar 10 mei 2011
 
UI Dev in Big data world using open source
UI Dev in Big data world using open sourceUI Dev in Big data world using open source
UI Dev in Big data world using open source
 
Putting the "Share" and "Point" back in SharePoint 2013
Putting the "Share" and "Point" back in SharePoint 2013Putting the "Share" and "Point" back in SharePoint 2013
Putting the "Share" and "Point" back in SharePoint 2013
 
Django è pronto per l'Enterprise
Django è pronto per l'EnterpriseDjango è pronto per l'Enterprise
Django è pronto per l'Enterprise
 
Pimping the ForgeRock Identity Platform for a Billion Users
Pimping the ForgeRock Identity Platform for a Billion UsersPimping the ForgeRock Identity Platform for a Billion Users
Pimping the ForgeRock Identity Platform for a Billion Users
 
Oracle - Document Life - 6apr2012
Oracle - Document Life - 6apr2012Oracle - Document Life - 6apr2012
Oracle - Document Life - 6apr2012
 
DIGIT Noe 2016 - Overview of front end development today
DIGIT Noe 2016 - Overview of front end development todayDIGIT Noe 2016 - Overview of front end development today
DIGIT Noe 2016 - Overview of front end development today
 
Oracle Application Management Suite
Oracle Application Management SuiteOracle Application Management Suite
Oracle Application Management Suite
 

Último

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Último (20)

Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 

Single page application

  • 1. Single Page Applications 李濬志 Jeremy Lee @junzhli
  • 2. “A Single Page Application is a web app that fits on a single page with a goal of providing a more fluid user experience” from wikipedia
  • 3. Web Apps not Web Sites
  • 4. Web Apps • Like desktop applications (Word, Photoshop, Skype) • Dynamic and ever-changing • Rely on you to interact with them • Contributing content. (Facebook, Youtube, Twitter) • Gathering data from other sources and presenting it to you • Always use databases (PHP, Ruby, Python, framework Rails)
  • 5.
  • 6. Characteristics • 如同應⽤用程式操作特性 • URL hash • 更豐富的互動界⾯面 • 資料動態載⼊入 • 允許離線使⽤用 • 先載⼊入必要檔案即可 • …
  • 9. SPA Benefit • 效能提升 • 更少的資料傳輸 • 更多回應放到 Client 處理 • 分散式載⼊入 (Load distribution) • 快取 (Cache) • 跨平台 • 程式碼更易維護 • 響應式網⾴頁設計 (Responsive Web Design)
  • 10. 技術層⾯面 • XML, JSON and AJAX • HTML DOM • CSS • JavaScript Frameworks • HTML5 WebSockets • HTML5 Web Storage
  • 11.
  • 13. Feature Angular Backbone Ember Observables V V V Routing V V V View bindings V V Two way bindings V V Partial views V V Filtered list views V V
  • 14. Learning curve and documentation • Backbone • Ember • Angular
  • 15. Size Angular Backbone Ember 80k 18k 141k Size with dependencies Backbone needs at least Underscore and Zepto Ember needs jQuery and Handlebars 61K 269K
  • 17. Single Page Application with AngularJS • Open-source web application framework • model–view–controller (MVC) capability • Two-way Data Binding
  • 18.
  • 19. Controller • 負責將 ViewModel 與 View 結合產⽣生 UI • ⼀一個網⾴頁裡可以有多個 Controller 負責不同元素 的 Binding
  • 21. Templete • 在 HTML 中預先定義好的 Angular 特殊元素 • Directive, Markup, Filter, Form controls
  • 22. Directive • 賦予 Attribute 或 Element 的相關 DOM 元素額外功能 • like ngBind, ngModel, and ngView • 可⾃自定義 Directive
  • 23. Filter • 應⽤用於 Directive,對繫結的資料進⾏行後置處理 • {{ expression | filter1 | filter2 | ... }} • {{ 1234 | number:2 }}
  • 24. Service • 跨 Controller 的功能邏輯 • 內部服務 (Internal Service) $resource service
  • 25. Router • $route service : $routeProvider • 瀏覽器導覽按鈕解決⽅方案 • Bookmarkable
  • 26. Hello World ! Demo 1 • Angular module 存取範圍宣告 : ng-app • Markup : {{sometext}} • ng-bind=“sometext” • Directive : ng-init, ng-show, ng-hide • Filter : {{ sometext | uppercase }}
  • 27. Todo List part1 Demo 2 • angular.module('Todo', []) • angular.module(‘Todo’, []).controller(‘todoController’, …) • View 與 model 橋樑 : $scope • 與外部 View 直接存取 : $scope.todos • $scope.addTodo = function(){ … }
  • 29. Todo List part2 Demo 2 • $scope.todos.push({'title':$scope.newTodo, ‘done':false}) • ng-controller=“todoController” • ng-repeat="todo in todos” • ng-disabled=“doWhat.$invaild" • ng-submit=“addTodo()" • ng-class=“{'done':todo.done}"
  • 30. Routing Demo 3 • <a href=“#One"> • <div ng-view></div> • sampleApp.config([‘$routeProvider’, …]) • sampleApp.controller(‘OneController' …)
  • 32. Photo Gallery Demo 4 • angular.module(‘photoApp’).factory('photoSearchService', …) • var service = {}; • service.findPhotos = function(keyword, callback) { … }
  • 34. Reference • http://viralpatel.net/blogs/angularjs-routing-and-views-tutorial-with-example/ • http://blog.miniasp.com/post/2013/04/24/Front-end-Engineering-Fineart-An-Introduction-to-AngularJS.aspx • http://www.dotnet-tricks.com/Tutorial/designpatterns/2FMM060314-Understanding-MVC,-MVP-and-MVVM-Design- Patterns.html • http://blogs.bluepi.in/2014/08/04/why-single-page-application/ • http://www.adobe.com/devnet/html5/articles/getting-started-with-angularjs.html • http://plexusweb.com/2013/04/web-site-vs-web-application-whats-the-difference/ • http://en.wikipedia.org/wiki/Single-page_application • http://codepen.io/Russbrown/pen/IgBuh • http://blog.codeschool.com/post/85819292538/angular-backbone-or-ember-which-is-best-for-your