使用Yeoman搭建 AngularJS 应用 (9) —— 让我们搭建一个网页应用
原文地址:http://yeoman.io/codelab/install-packages.html
列出当前程序包
我们现在查看一下我们已经安装的程序包,输入下面的命令
bower list

查找程序包
为了核实AngularUI程序包是有效的,使用Bower来查找 "angular-ui-sortable"
bower search angular-ui-sortable
这个是一个 "angular-ui-sortable" 的结果,所以让我们安装JQuery UI和angular-ui-sortable
安装程序包
使用Bower来安装 "angular-ui-sortable" 和 “jquery-ui”
bower install --save angular-ui-sortable
bower install --save jquery-ui
这个 --save选项会更新bower.json文件中的angular-ui-sortable和jquery-ui。

确认安装
让我们看看bower_components来检查以上的操作,你可以看到 "jquery-ui" 和 "angular-ui-sortable" 安装在这个文件夹中

排列todos列表
引用新的依赖文件,必须将文件添加到index.html。你可以手动的添加AugularUI Sortable和jQeuryUI文件,但是Yeoman可以自动做这些。
使用Ctrl + C来退出当前的服务
再次输入 grunt server
你将看到index.html中script节点底部添加了jquery-ui/ui/jquery-ui.js和angular-ui-sortable/sortable.js
<!-- build:js scripts/vendor.js -->
<!-- bower:js -->
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>
<script src="bower_components/angular-animate/angular-animate.js"></script>
<script src="bower_components/angular-cookies/angular-cookies.js"></script>
<script src="bower_components/angular-resource/angular-resource.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
<script src="bower_components/angular-touch/angular-touch.js"></script>
<script src="bower_components/jquery-ui/jquery-ui.js"></script>
<script src="bower_components/angular-ui-sortable/sortable.js"></script>
<!-- endbower -->
<!-- endbuild -->
为了使用Sortable模块,你必须更新scripts/app.js,现在看看起来如下面所示
angular
.module('mytodoApp', [
'ngAnimate',
'ngCookies',
'ngResource',
'ngRoute',
'ngSanitize',
'ngTouch'
])
在ngTouch之后添加ui.sortable
angular
.module('mytodoApp', [
'ngAnimate',
'ngCookies',
'ngResource',
'ngRoute',
'ngSanitize',
'ngTouch',
'ui.sortable'
])
最后,我们在main.html添加ui-sortable指令
<!-- Todos list -->
<div ui-sortable ng-model="todos">
<p class="input-group" ng-repeat="todo in todos">
再次添加css类型让我们可以移动todo元素
<p class="input-group" ng-repeat="todo in todos" style="padding:5px 10px; cursor: move;">
全部的todo列表如下所示
<!-- Todos list -->
<div ui-sortable ng-model="todos">
<p class="input-group" ng-repeat="todo in todos" style="padding:5px 10px; cursor: move;">
<input type="text" ng-model="todo" class="form-control">
<span class="input-group-btn">
<button class="btn btn-danger" ng-click="removeTodo($index)" aria-label="Remove">X</button>
</span>
</p>
</div>
再次运行grunt server并且看看浏览器,我们就可以重新排序列表了


使用Yeoman搭建 AngularJS 应用 (9) —— 让我们搭建一个网页应用的更多相关文章
- 使用Yeoman搭建 AngularJS 应用 (12) —— 让我们搭建一个网页应用
原文地址:http://yeoman.io/codelab/local-storage.html 安装Bower程序包 我们使用另一个Angular模块,"angular-local-sto ...
- 使用Yeoman搭建 AngularJS 应用 (5) —— 让我们搭建一个网页应用
原文地址:http://yeoman.io/codelab/scaffold-app.html 基架 (Scaffolding) 在Yeoman中的意思是为基于你特殊的配置需求,为网站程序生成文件的工 ...
- 使用Yeoman搭建 AngularJS 应用 (4) —— 让我们搭建一个网页应用
在开发一个的网页传统工作流程中,你需要大量的时间去设置引用文件,下载依赖文件,并且手动的创建网页文件结构.Yeoman生成器将会帮助你完成这些.让我们安装一个AngularJS项目的生成器. 安装An ...
- 使用Yeoman搭建 AngularJS 应用 (2) —— 让我们搭建一个网页应用
原文地址:http://yeoman.io/codelab/index.html 使用Yeoman搭建简单的应用 今天将会搭建一个简单的网页程序.你将可以添加,删除,拖拽和保存. 浏览Yeoman Y ...
- 使用Yeoman搭建 AngularJS 应用 (11) —— 让我们搭建一个网页应用
原文地址:http://yeoman.io/codelab/prepare-production.html 让我们发布这个应用 优化产品的文件 为了创建应用的产品版本,我们想做如下的事情 检查你的代码 ...
- 使用Yeoman搭建 AngularJS 应用 (10) —— 让我们搭建一个网页应用
原文地址:http://yeoman.io/codelab/write-unit-tests.html 对于不熟悉的Karma的人来说,这是JavaScript测试框架,这个Angular的生成器包含 ...
- 使用Yeoman搭建 AngularJS 应用 (8) —— 让我们搭建一个网页应用
原文地址:http://yeoman.io/codelab/write-app.html 创建一个新的模板来显示一个todo的列表 打开views/main.html 为了从一个干净的模板开始,删除m ...
- 使用Yeoman搭建 AngularJS 应用 (7) —— 让我们搭建一个网页应用
原文地址:http://yeoman.io/codelab/preview-inbrowser.html 开启你的服务 运行Grunt任务,通过输入下面的命令来创建一个本地Node的http服务,地址 ...
- 使用Yeoman搭建 AngularJS 应用 (6) —— 让我们搭建一个网页应用
原文地址:http://yeoman.io/codelab/review-generated-files.html 打开mytodo文件夹,你会看到现在的基架.如下图所示 在mytodo文件夹,我们能 ...
随机推荐
- Javascript之响应式相册
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/stri ...
- mysql 游标嵌套循环实例
BEGIN #Routine body goes here... ####所有的2个小时之前生成的待支付订单更新为已过期 DECLARE tmp_id INT; DECLARE tmp_order_i ...
- crackme_zapline分析
[破文标题]crackme_zapline 分析 [破文作者]CloAk [作者邮箱]@qq.com [作者主页] [破解工具]OD,... [破解平台]Windows --------------- ...
- Entity Framework问题:ReferentialConstraint 中的依赖属性映射由存储生成的列
原文:Entity Framework问题:ReferentialConstraint 中的依赖属性映射由存储生成的列 今天在采用Entity Framework 的Database First反向以 ...
- Yii Framework处理网站前后台文件的方法
此方法参考官方网站的cookbook,详细请看http://www.yiiframework.com/doc/cookbook/33/, 我在此基础上做了一些改动,人个感觉非常棒了,大家可以试一下! ...
- Swift静态方法
与静态属性类似,Swift中还定义了静态方法,也称为类型方法,所谓“类型”是指枚举.结构体和类.静态方法定义的方法也是与静态属性类似的,枚举和结构体的静态方法使用的关键字是static,类的静态方法使 ...
- 翻译:如何编译 Gunz 源代码
如何编译 Gunz 源代码 本文翻译自:How to build Gunz source code 各位好,近期 Dawson 发布了 Gunz 的源代码,所以我就来做个简单的教程,来说明如何编译 G ...
- SQL Server 收缩事务日志的方法
由于SQL2008对文件和日志管理进行了优化,所以以下语句在SQL2005中可以运行但在SQL2008中已经被取消:(SQL2005) Backup Log DataBaseName with no_ ...
- wp8 自定义相机+nokia滤镜+录制amr音频
demo截图: 代码量有点多,就不贴出来了. 备注: 1.自定义相机主要横竖屏时,对相机进行旋转. 2.播放amr格式可以在页面中直接添加MediaElement控件进行播放,或者使用Bac ...
- doctype的种类
现实生活中人们使用的浏览器是各式各样的!为了防止各各浏览器页面设置不一样而照成我们所做的网页乱序,不得不设置doctye(文档类型):doctype有3中类型:* 过渡的(Transitional): ...