结构-行为-样式-angularJs ngAnimate(Js实现)
发布时间:2020-12-17 10:13:32 所属栏目:安全 来源:网络整理
导读:声明 页面 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-contro
一、声明注意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>
三、Jsvar 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
},done);
return function(isCancelled) {
if(isCancelled) {
jQuery(element).stop();
}
}
},move:function(element,done){
//do not used
}
};
});
四、注意事项1、Angular的版本与Angular-animate的版本要一致,不然会报错; 五、官方链接Angularjs-ngAnimate官方Api (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |