打造高性能移动应用:从手势交互到性能优化
1. 为移动设备打造应用
在移动设备上,传统的书签列表分页小部件并不实用,人们更倾向于使用滑动手势来快速浏览内容。在 AngularJS 中,添加触摸支持变得前所未有的简单。
1.1 安装 angular-touch 模块
由于 angular-touch 模块不包含在核心中,需要单独安装:
bower install --save angular-touch
1.2 在 index.html 中引用 angular-touch.js
在 angular-route.js 之后引用 angular-touch.js:
<script src="bower_components/angular-touch/angular-touch.js"></script>
1.3 在 app.js 中添加依赖
将 ngTouch 模块作为依赖添加到 app.js 中:
angular.module('myApp', ['ngRoute', 'ngTouch', 'myApp.controllers', 'myApp.services'])
.config(function($routeProvider){
$routeProvider.when('/
超级会员免费看
订阅专栏 解锁全文
956

被折叠的 条评论
为什么被折叠?



