SlideShare a Scribd company logo
AngularJS 開發 ASP.NET MVC
jQuery 寫膩了嗎?換個新東西吧!
Bibby Chung
http://bibby.be
http://mvc.tw/0014
微軟最有價值專家(ASP.NET)
twMVC 聯合創辦人之一
獨立手機 APP 軟體開發
2
講者簡介
Bibby Chung
http://bibby.be
現代化的網頁程式
功能越來越多
user experience 越來越重視
jQuery 玩膩了寫煩了
不想再 DOM 來 DOM 去了
Single Page Application (SPA)
3
動機
4
需要一些改變
5
開始
6
開始
AngularJS 可以吃嗎?
7
開始
8
開始
優點是?
9
AngularJS 優點
Code 會少很多
10
AngularJS 優點
From Google I/O 2013
11
AngularJS 優點
重用模組化
12
AngularJS 優點
13
AngularJS 優點
易測試
14
AngularJS 優點
15
AngularJS 優點
雙向綁定
16
AngularJS 優點
17
AngularJS 功能
功能很多很多很多
1818
功能
Data Binding
Services
Directives
Views
Controllers
Models
Factories
Templates jqLite
Testing
Routing
MVC/MVVM/MVX
Validation
Dependency Injection
19
功能
Data Binding
Services
Directives
Views
Controllers
Models
Factories
Templates jqLite
Testing
Routing
MVC/MVVM/MVX
Validation
Dependency Injection
20
怎麼開始
Getting Started
 第一步
21
怎麼開始
<html ng-app>
or
<script>
var app = angular.module('app', [/* deps */]);
angular.bootstrap(document, ['app']);
</script>
 第二步
22
怎麼開始
到 NuGet 下載 AngularJS
<script src="~/Scripts/angular.js">
</script>
23
怎麼開始
簡單的 Binding
簡單的 For Loop
24
Directives, Filters and Data Binding
Demo
 什麼是 Directive
 像一個 Html Tag
 定義作用或作用域
 想成 HTML 開外掛
25
Directives, Filters and Data Binding
Html Tag
作用或作用域
Component
 有哪些 Directives
 官網
26
Directives, Filters and Data Binding
ng-app
ng-model
ng-init
ng-repeat
ng-show
ng-controller
ng-click
filters
lowercase, uppercase
filter:predicate.$
27
Directives, Filters and Data Binding
28
Directives, Filters and Data Binding
Demo
filters
orderBy:‘PropertyName’
orderBy:[‘PropertyName’,‘-PropertyName’]
29
Directives, Filters and Data Binding
30
Directives, Filters and Data Binding
Demo
31
Views, Controllers and Scope
32
Views, Controllers and Scope
設定Controller
設定Controller
33
Views, Controllers and Scope
View
Controller
$scope
34
Views, Controllers and Scope
Demo
35
Views, Controllers and Scope
要改變,從 Model 開始
36
Views, Controllers and Scope
37
Modules, Routes and Services
BUT..
38
Modules, Routes and Services
這樣寫還不夠,只能當水母
39
Modules, Routes and Services
40
Modules, Routes and Services
41
Modules, Routes and Services
42
Modules, Routes and Services
設定的Module設定的Controller
43
Modules, Routes and Services
Demo
Routes
 Single Page Application(SPA)
Services
 獨體模式(Singleton)
 適合 Controller 跟 Controller 的聯繫
Factories
 任何想要模組共用的都可以丟到這裡
44
Modules, Routes and Services
45
Modules, Routes and Services
設定Route
http://localhost:7228/Test/Demo6#/Normal
46
Modules, Routes and Services
設定Factories
47
Modules, Routes and Services
設定Services
48
Modules, Routes and Services
Demo
49
其他
50
其他
硬的就只有一點點
別擔心
AngularJS 基本上是簡單的
51
其他
常見的問題
52
其他
之前用 jQuery
現在用 AngularJS
會不會有問題?
 回答
 可以協同作業,不過可以角色互換一下,以 AngularJS 為主,
讓 AngularJS 架構模組化及雙向Binding,讓 jQuery 來處
理特效等其它部分
 不要再用 DOM 來操作頁面上的 Element 了
 內建有 jsLite 可以操作 DOM
 用 AngularJS 寫出來的 Code 是可測試性的
 讓程式朝著對的方向前進
53
其他
54
其他
今天主題不是
ASP.NET MVC
開發
AngularJS
那另一個主角呢?
回答
 ASP.NET MVC 的 View 會越用越少
程式都會移到 AngularJS 來設計
 AJAX 越用越多,JSON 來 JSON 去,ASP.NET MVC 很
單純的變成資料供應者
 很多的程式都被移到前端來處理了,前端的程式滿天飛,
需要有好的方式來管理前端撰寫
55
其他
56
其他
那 AngularJS 的缺點呢?
回答
 SEO
 http://mvc.tw/000z
 需要專業的人
不能再是跑龍套的角色
 Debug
訊息並不是每次都很明顯,有時要靠資質直覺
57
其他
58
其他
應該還有時間!
 Visual Stuido 2012 Intellisense
 http://mvc.tw/000y
 支援的瀏覽器
 官方說法,保證支援現代化的瀏覽器
 偵錯及效能工具 AngularJS Batarang
 http://mvc.tw/0010
59
其他
 如果你的 JS 需要最小化(Minify),請這樣寫
 myApp.controller("PersonCtrl",[‘$scope’,’$location
’, function ($scope,$location) {/*..*/}]);
60
其他
61
其他
結論
62
其他
找一個小專案
來 TRY 就會發現問題了
63
其他
 官網 (英文) http://angularjs.org/
 AngularJS 中文社區 (阿六仔) http://angularjs.cn/
 Youtube 官網教學 http://mvc.tw/0012
 Dan Wahlin 教學影片 http://mvc.tw/0011
 加入 Facebook 的 AngularJS.tw 社團
64
資源
65
資源
From Google I/O 2013
 Blog  http://bibby.be
 Facebook  http://fb.me/bibbynet
 Plurk  http://www.plurk.com/bibbynet
66
聯絡我
Bibby Chung
http://bibby.be
謝謝各位
• 本投影片所包含的商標與文字皆屬原著作者所有。
• 本投影片使用的圖片皆從網路搜尋。
• 本著作係採用 Creative Commons 姓名標示-非商業性-相同方式分享 3.0 台灣 (中華民國) 授權條款授權。
h t t p : / / m v c . t w

More Related Content

What's hot (18)

PPTX
輕鬆上手ASP.NET Web API 2.1.2
Bruce Chen
 
PDF
使用 ASP.NET MVC 開發SPA網站-微軟實戰課程日
twMVC
 
PPTX
KSDG-ASP.NET MVC 5 Overview (偽三國誌)
Bruce Chen
 
PPTX
Mvc架構說明
Kemie Lin
 
PDF
架構設計入門 twMVC#11
twMVC
 
PPTX
Angular.js & ASP.NET in Study4
Kyle Shen
 
PDF
ASP.NET MVC 內建驗證擴充與活用技巧 -twMVC#3
twMVC
 
PDF
ASP.NET MVC 4 新功能介紹(快速上手) -twMVC#4
twMVC
 
PPTX
ASP.NET MVC 善用網路資源快速完打造網站
twMVC
 
PDF
一小時可以打造什麼服務Plus twMVC#18
twMVC
 
PPTX
MVC實戰分享 分頁與排序相關技巧-tw mvc#13
twMVC
 
PDF
SignalR實戰技巧 twmvc#17
twMVC
 
PPTX
Asp.net mvc 概觀介紹
Alan Tsai
 
PDF
twMVC#20 | ASP.NET MVC View 開發技巧小錦囊
twMVC
 
PPTX
Study4 love.2016.2.20.ionic
Kyle Shen
 
PDF
twMVC#19 | 微信公眾平台申請與wechat api 開發血淚史
twMVC
 
PDF
Asp.net mvc網站的從無到有
Wade Huang
 
PDF
如何在實務上使用TDD來開發 twmvc#12
twMVC
 
輕鬆上手ASP.NET Web API 2.1.2
Bruce Chen
 
使用 ASP.NET MVC 開發SPA網站-微軟實戰課程日
twMVC
 
KSDG-ASP.NET MVC 5 Overview (偽三國誌)
Bruce Chen
 
Mvc架構說明
Kemie Lin
 
架構設計入門 twMVC#11
twMVC
 
Angular.js & ASP.NET in Study4
Kyle Shen
 
ASP.NET MVC 內建驗證擴充與活用技巧 -twMVC#3
twMVC
 
ASP.NET MVC 4 新功能介紹(快速上手) -twMVC#4
twMVC
 
ASP.NET MVC 善用網路資源快速完打造網站
twMVC
 
一小時可以打造什麼服務Plus twMVC#18
twMVC
 
MVC實戰分享 分頁與排序相關技巧-tw mvc#13
twMVC
 
SignalR實戰技巧 twmvc#17
twMVC
 
Asp.net mvc 概觀介紹
Alan Tsai
 
twMVC#20 | ASP.NET MVC View 開發技巧小錦囊
twMVC
 
Study4 love.2016.2.20.ionic
Kyle Shen
 
twMVC#19 | 微信公眾平台申請與wechat api 開發血淚史
twMVC
 
Asp.net mvc網站的從無到有
Wade Huang
 
如何在實務上使用TDD來開發 twmvc#12
twMVC
 

Similar to twMVC#09 | AngularJS 開發 ASP.NET MVC (14)

PPTX
深入研究 Angular - phoebe pan
Phoebe Pan
 
PDF
Angular js twmvc#17
twMVC
 
PDF
Angular js 入門介紹
wantingj
 
PDF
twMVC#17 | 使用Angular.js開發大型系統架構
twMVC
 
PDF
AngularJS training in Luster
Jason Chung
 
PPTX
快快樂樂學會 Angular 2 網站開發框架 (Modern Web 2016)
Will Huang
 
PDF
Angular從入門到實戰(一)
志龍 陳
 
PDF
JS and NG - ntut iLab 2015/07/14
BO Hong LI
 
PPTX
Angular 基礎教育訓練
得霖 廖
 
PDF
Angular js入门分享 by 王栋
栋 王
 
PPTX
2016年逢甲大學資訊系:ASP.NET MVC 4 教育訓練3
Duran Hsieh
 
PPTX
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例
Will Huang
 
PDF
程式人雜誌 -- 2013年7月號
鍾誠 陳鍾誠
 
PDF
程式人雜誌 -- 2013年8月號
鍾誠 陳鍾誠
 
深入研究 Angular - phoebe pan
Phoebe Pan
 
Angular js twmvc#17
twMVC
 
Angular js 入門介紹
wantingj
 
twMVC#17 | 使用Angular.js開發大型系統架構
twMVC
 
AngularJS training in Luster
Jason Chung
 
快快樂樂學會 Angular 2 網站開發框架 (Modern Web 2016)
Will Huang
 
Angular從入門到實戰(一)
志龍 陳
 
JS and NG - ntut iLab 2015/07/14
BO Hong LI
 
Angular 基礎教育訓練
得霖 廖
 
Angular js入门分享 by 王栋
栋 王
 
2016年逢甲大學資訊系:ASP.NET MVC 4 教育訓練3
Duran Hsieh
 
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例
Will Huang
 
程式人雜誌 -- 2013年7月號
鍾誠 陳鍾誠
 
程式人雜誌 -- 2013年8月號
鍾誠 陳鍾誠
 
Ad

More from twMVC (20)

PDF
twMVC#51 以平台工程重新思考系統設計 - 以 Batch System 為例封面
twMVC
 
PDF
twMVC#51-GitHub Copilot 徹底改變開發模式,探索 AI 驅動的智慧程式碼協作
twMVC
 
PDF
twMVC#50 微服務上線後的救贖
twMVC
 
PDF
twMVC 47_Elastic APM 的兩三事
twMVC
 
PDF
twMVC#46_SQL Server 資料分析大躍進 Machine Learning Services
twMVC
 
PDF
.NET 7 家族新成員: Microsoft Orleans v7
twMVC
 
PDF
twMVC#46 一探 C# 11 與 .NET 7 的神奇
twMVC
 
PDF
twMVC#44 如何測試與保護你的 web application with playwright
twMVC
 
PDF
twMVC#44 讓我們用 k6 來進行壓測吧
twMVC
 
PDF
twMVC#43 Visual Studio 2022 新功能拆解
twMVC
 
PDF
twMVC#43 YARP
twMVC
 
PDF
twMVC#43 C#10 新功能介紹
twMVC
 
PDF
twMVC#42 Azure DevOps Service Pipeline設計與非正常應用
twMVC
 
PDF
twMVC#42 Azure IoT Hub for Smart Factory
twMVC
 
PDF
twMVC#42 Windows容器導入由0到1
twMVC
 
PDF
twMVC#42 讓我們用一種方式來開發吧
twMVC
 
PDF
twMVC#41 hololens2 MR
twMVC
 
PPTX
twMVC#41 The journey of source generator
twMVC
 
PDF
twMVC#38 How we migrate tfs to git(using azure dev ops)
twMVC
 
PDF
twMVC#36C#的美麗與哀愁
twMVC
 
twMVC#51 以平台工程重新思考系統設計 - 以 Batch System 為例封面
twMVC
 
twMVC#51-GitHub Copilot 徹底改變開發模式,探索 AI 驅動的智慧程式碼協作
twMVC
 
twMVC#50 微服務上線後的救贖
twMVC
 
twMVC 47_Elastic APM 的兩三事
twMVC
 
twMVC#46_SQL Server 資料分析大躍進 Machine Learning Services
twMVC
 
.NET 7 家族新成員: Microsoft Orleans v7
twMVC
 
twMVC#46 一探 C# 11 與 .NET 7 的神奇
twMVC
 
twMVC#44 如何測試與保護你的 web application with playwright
twMVC
 
twMVC#44 讓我們用 k6 來進行壓測吧
twMVC
 
twMVC#43 Visual Studio 2022 新功能拆解
twMVC
 
twMVC#43 YARP
twMVC
 
twMVC#43 C#10 新功能介紹
twMVC
 
twMVC#42 Azure DevOps Service Pipeline設計與非正常應用
twMVC
 
twMVC#42 Azure IoT Hub for Smart Factory
twMVC
 
twMVC#42 Windows容器導入由0到1
twMVC
 
twMVC#42 讓我們用一種方式來開發吧
twMVC
 
twMVC#41 hololens2 MR
twMVC
 
twMVC#41 The journey of source generator
twMVC
 
twMVC#38 How we migrate tfs to git(using azure dev ops)
twMVC
 
twMVC#36C#的美麗與哀愁
twMVC
 
Ad

twMVC#09 | AngularJS 開發 ASP.NET MVC