21
AngularJS in Mobile Web App

Angularjs in mobile app

Embed Size (px)

DESCRIPTION

why we choose AngularJS as our mobile web app framework.

Citation preview

Page 1: Angularjs in mobile app

AngularJS in Mobile Web App

Page 2: Angularjs in mobile app

前期提要

● phonegap● AngularJS

○ m-v-whatever 架構

● 畫面○ Font Icon○ scss/sass○ css3 - animation

Page 3: Angularjs in mobile app

Why we choose angular?

● Developed by Google● Open Source● Single Page Applications [SPA]● Comprehensive

○ Templates and Directives○ Two-way Data Binding○ Dependency Injection○ Routing

Page 4: Angularjs in mobile app

Single Page Applications In Mobile

● logic architecture build in client○ 畫面改變不需要透過 server 端

● 'Application like' 互動○ css3 transition, 過場動畫效果

● Back/Forward work well ○ 採用 bookmark 的方式, url 加上 # ○ 追蹤 (Android back button, call url history)

● can be made Offline

Page 5: Angularjs in mobile app

2-way data bindingJS

HTML

Page 6: Angularjs in mobile app
Page 7: Angularjs in mobile app
Page 8: Angularjs in mobile app

Templates

● view 是 template 加上 model 跟 controller 結合後所產生出來的動態畫面 ○ MVC架構

● Angular element and attributes:○ Markup

■ 兩個大括號 {{}} ■ angular put model in html

○ Directive○ Filter

Page 9: Angularjs in mobile app
Page 10: Angularjs in mobile app

Template with Controller JS

HTML

Page 11: Angularjs in mobile app

Async Templates

AngularJS loads template asynchronously.

Page 12: Angularjs in mobile app

Template with Filter

Format data to display● date, number, orderby, etc.

Page 13: Angularjs in mobile app

Directives

● reusable DOM● augments an existing DOM

HTML

Page 14: Angularjs in mobile app

Dependency Injection

reuse service ● error handler

Page 15: Angularjs in mobile app

mock data

replace service easily

Page 16: Angularjs in mobile app

RoutingHTML

HTML

JS

Page 17: Angularjs in mobile app

效能改善

● local storage ● gzip● Ionic framework

Page 18: Angularjs in mobile app

local storage ● 第一次 call service 後, 就儲存在 local storage ● 資料更新方法

○ 每次登入重新更新○ user reload○ 在需要準確資料的時候更新

■ 基本資訊畫面● 成果:

○ 每次在主畫面重新 reload 都要花 8s -> 1s render 畫面的時間

○ 重複進入 task 時, 不會花時間去撈資料

Page 19: Angularjs in mobile app

gzip

Tomcat 設定

Header

compress response size

Page 20: Angularjs in mobile app

Ionic Framework

“Create hybird mobile apps with the web technologies you love”● minimal DOM manipulation, zero jQuery,

and hardware accelerated ● AngularJS● open source, code pen

Page 21: Angularjs in mobile app

Thank YouAny Question?