结构-行为-样式-angularJs ngAnimate(Js实现)
2016-04-07 23:12
555 查看
声明
页面
Js
注意事项
官方链接
2、一个App内不能声名相同名字的Controller;
3、上面例子只是ng-repeat的版本,其实还有其他版本;
4、ng-repeat只用到了Animate声明Js版本中的enter,leave和move三个方法;
5、有时候只控制高度就可以达到效果;
页面
Js
注意事项
官方链接
一、声明
注意animate的版本要与Angular的一致。<script src="jquery.1.9.1.min.js"></script> <script src="angular.js"></script> <script src="angular-animate.js"></script>
二、页面
<body ng-app="myApp" ng-controller="myCtrl"> <div class="container"> <h3>Animation-js</h3> <form class="form-search"> <div class="input-append"> <input type="text" ng-model="search" placeholder="Search user" class="form-control" > </div> <ul class="example-animate-container"> <li class="animate-repeat" ng-repeat="user in users | filter:search"> <a href="#"> {{user}} </a> </li> </ul> </form> </div> </body>
三、Js
var app = angular.module('myApp', ['ngAnimate']); app.controller('myCtrl',['$scope',function($scope){ $scope.users = ['Fabio', 'Leonardo', 'Thomas', 'Gabriele', 'Fabrizio', 'John', 'Luis', 'Kate', 'Max']; }]); app.animation('.animate-repeat',function(){ return { enter:function(element,done){ $(element).css({opacity:0}); jQuery(element).animate({ opacity: 1, height:40 },300, done); return function(isCancelled) { if(isCancelled) { jQuery(element).stop(); } } }, leave:function(element,done){ jQuery(element).animate({ opacity:0, height:0 },300, done); return function(isCancelled) { if(isCancelled) { jQuery(element).stop(); } } }, move:function(element,done){ //do not used } }; });
四、注意事项
1、Angular的版本与Angular-animate的版本要一致,不然会报错;2、一个App内不能声名相同名字的Controller;
3、上面例子只是ng-repeat的版本,其实还有其他版本;
4、ng-repeat只用到了Animate声明Js版本中的enter,leave和move三个方法;
5、有时候只控制高度就可以达到效果;
五、官方链接
Angularjs-ngAnimate官方Api相关文章推荐
- angular中关于如何传id以及其他参数的
- angular中 modal模态框(可复用)
- Angularjs Controller 间通信机制
- angularjs How to set focus on input field?
- AngularJS中ng-options简单用法及预选项失败的原因
- angularjs注意点
- 通过路由管理视图间切换 - AngularJS路由解析
- AngularJs 过滤器
- AngularJs 简单数据绑定
- AngularJs 使用 $timeout
- Angularjs基础教程
- AngularJs 弹出模态框(model)
- 详解AngularJS 模态对话框
- 理解angular中的module和injector,即依赖注入
- AngularJS 模态对话框
- AngularJS 1.x学习<2>
- [置顶] 跟我学AngularJs:AngularJs入门及第一个实例
- [Angular 2] *ngFor with index
- AngularJS 1.x学习<1>
- 详解AngularJS 模态对话框