×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Christopher Melville
Added: Jan 18, 2017 2:11 PM
Views: 19
Animations within custom directives can also be established by injecting $animate directly into your directive and making calls to it when needed.
  1. myModule.directive('my-directive', ['$animate', function($animate) {
  2.   return function(scope, element, attrs) {
  3.     element.on('click', function() {
  4.       if(element.hasClass('clicked')) {
  5.         $animate.removeClass(element, 'clicked');
  6.       } else {
  7.         $animate.addClass(element, 'clicked');
  8.       }
  9.     });
  10.   };
  11. }]);