1

I've got an app that uses a javascript animation.

When I run the build, grunt minifies and uglifies the code and creates a file 'vendor.js' containing all the library js code including angular. However the code that is generated is broken when I use my animate method shown below.

The error I see in the browser console is caused by the minified and uglified vendor.js

Error: [$injector:unpr] Unknown provider: aProvider <- a

I may need to find a different approach to what I am doing, but I'd still like to address this problem specifically if possible.

In the following code I'm using angular to get access to the global rootscope as I want to trigger an action higher in the scope hierarchy than the element where the animation is registered.

Without this added behaviour, the animations are all working correctly, so there is no problem with the actual libraries that are ending up in vendor.js The answer may be to turn off uglification, or find a way to copy this specific script directly to the target instead of passing it through magnification and uglification.

angular.module('myApp').animation('.theme-content', function() {
return {
    enter: function(element, done) {
       var  rootScope = angular.element(document).injector().invoke(function($rootScope){return $rootScope;});
       rootScope.$broadcast('page-start-animation',  null ); 
      return function(cancelled) {
      };
    },
    leave: function(element, done) { },
    move: function(element, done) { }, 
    beforeAddClass: function(element, className, done) { }, 
    addClass: function(element, className, done) { }, 
    beforeRemoveClass: function(element, className, done) { }, 
    removeClass: function(element, className, done) { }
  };

});

4

0 回答 0