javascript - How to use ng-animate in angular 1.2? -
base
angular 1.1.5 - http://plnkr.co/edit/eokt8o4mjw9swdydeg3s?p=preview - works
upped
angular 1.2.6 - http://plnkr.co/edit/wopgatfnvm1mkf5li99h?p=preview - fail
i think did follow instructions docs - http://docs.angularjs.org/api/nganimate
• first include angular-animate.js in html
• load module in application adding dependent module
it's quite late in timezone , miss obvious. guess - css file between 1.1.5 , 1.2.6 not compatible? cannot tell...
anyway here code form upped plunker, included comments emphasise followed instructions docs:
<!doctype html> <html ng-app="app"> <head> <meta charset="utf-8"> <title>top animation</title> <script>document.write('<base href="' + document.location + '" />');</script> <link rel="stylesheet" href="style.css"> <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet"> <script src="http://code.angularjs.org/1.2.6/angular.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular-animate.js"></script> <!-- ^^^ load animate --> </head> <script> var app = angular.module('app', ['nganimate']); // <-- dependent module app.controller('ctrl', function($scope) { $scope.names = ['igor minar', 'brad green', 'dave geddes', 'naomi black', 'greg weber', 'dean sofer', 'wes alvaro', 'john scott', 'daniel nadasi']; }); </script> <body ng-controller="ctrl"> <div class="well" style="margin-top: 30px; width: 200px; overflow: hidden;"> <form class="form-search"> <div class="input-append"> <input type="text" ng-model="search" class="search-query" style="width: 80px"> <button type="submit" class="btn">search</button> </div> <ul class="nav nav-pills nav-stacked"> <li ng-animate="'animate'" ng-repeat="name in names | filter:search"> <a href="#"> {{name}} </a> </li> </ul> </form> </div> </body> </html>
many help!
here working version of plunker... http://plnkr.co/edit/05irgvywd4y9zrb1zhsw?p=preview
in angular 1.2+, don't need declare ng-animate directive anymore. animations can added css alone. example, can remove ng-animate directive , give element css class, change...
<li ng-animate="'animate'" ng-repeat="name in names | filter:search"> to... <li class="animate" ng-repeat="name in names | filter:search">
and update css ...
.animate.ng-enter, .animate.ng-leave { ... .animate.ng-leave.animate.ng-leave-active, .animate.ng-enter { ... .animate.ng-enter.ng-enter-active, .animate.ng-leave { ...
angular add ng-enter, ng-hide, ng-leave.. etc. classes element , remove them appropriately during animation lifecycle, trigger css animations. there list of directives support animation classes in docs under 'usage'. in example, animating ng-repeat, ng-enter, ng-leave , ng-move classes added our element @ appropriate time , can attach animations them css.
Comments
Post a Comment