javascript - AngularJS Trigger ng-animate when binding value change -
i have directive content bound via ng-html-bind-unsafe
. have transition when content changes. can use jquery fade out, change content value , fade in.
is there more elegant way angularjs ?
in angular 1.2.0 can use directive watches content changes , adds removes classes. can tie animation class adds , removes triggers fading effect looking for.
module.directive('contentchange', function(){ return { scope: { content: '=' }, template: '<span ng-bind-html="mycontent"></span>', link: function(scope, element, attrs){ scope.$watch('content', function(){ //add fader class element scope.mycontent = content; //remove fader class element }); }; });
here's popular article on 1.2 animations: http://www.yearofmoo.com/2013/08/remastered-animation-in-angularjs-1-2.html
Comments
Post a Comment