html - How do you actually get angular.js animation code from your javascript file to activate? -
down below app.controller starts, console.log statement (fourth line of angular.js code) renders output console. can explain why animation code not implemented? hg-repeat directive allow elements inside of div section repeated? grateful kind of help. thanks
app.js
var app = angular.module('tarasdeli', ['nganimate']); divinfo = [ { image: "someimage", time: "at /n" + "6:00 am...", happenstance: "shop opens /n" + "chefs prepare", }, { image: 'someimage', time: "at /n" + "11:30 am.../n" + "...12:00 pm/n" + "...12:30 pm/n" + "...1:00 pm/n", happenstance: "students flood deli /n" + "for lunch", }, { image: 'someimage', time: "at /n" + "4:00 am/n", happenstance: "deli closes", } ];
angular.js code apart of app.js
app.controller('fadeinout', function(){ this.maindivs = divinfo; }); app.animation('.repeated-item', [function(){ console.log('i work'); return { enter: function(element, done){ element.css('opacity', 0); $(element).animate({ opacity: 1 }, done); }, leave: function(element, done){ element.css('opacity', 1); $(element).animate({ opacity: 0 }, done); } }; }]);
html
the angular.js expressions reflect objects in divinfo array above. first image shows in view 2 other images suppose appear in view enter method executing. , angular.js code not seem render last 2 images in divinfo array view. also, i've downloaded angular-animate module via node.js , put dependency. scripts relied on @ bottom , correct(double-checked).
<div id = 'carousel-inner' ng-controller = 'fadeinout divcarousel'> <div ng-repeat = 'maindiv in divcarousel.maindivs' class = 'repeated-item'> <img ng-src = "{{ maindiv.image }}" /> <span>{{ maindiv.time }}</span> <p>{{ maindiv.happenstance }}</p> </div> </div>
the scripts depended on
<script src = "http://code.jquery.com/jquery-1.11.1.js"></script> <script type = 'text/javascript' src = '../node_modules/angular/angular.min.js'></script> <script src = "../node_modules/angular-animate/angular-animate.min.js"></script> <script type = "text/javascript" src = '../app.js'></script> <script src = '../js/deli.js'></script> <script src = '../js/mappingsys.js'></script>
tricky figure out what's wrong without complete example, apologize if i'm misunderstanding this. here's demo put code:
http://jsfiddle.net/y2aosl35/1/
according docs, animation events ng-repeat enter
, leave
, , move
: https://docs.angularjs.org/api/ng/directive/ngrepeat
so adding item divinfo array trigger enter
animation (i used $timeout, make clear in demo)
Comments
Post a Comment