I hit some problems minifying my Angular code so I turned on ng-strict-di
One problem seems to reside in the way I resolve a promise on a route in my app.js config
.when('/:userId', {
           templateUrl: 'views/main.html', 
           controller: 'MyCtrl',  
           resolve : {
               myDependency : function(Cache, Model, $route){ 
                  return Cache.getCached( $route.current.params.userId); 
               } 
           }
      })
Then I inject this resolved promise into the MyCtrl controller
angular.module('myApp') 
    .controller('MyCtrl',[ 'myDependency',  '$scope', '$rootScope', '$timeout', function (myDependency, $scope, $rootScope, $timeout) { 
 etc... 
However I get an error from Angular
[Error] Error: [$injector:strictdi] myDependency is not using explicit annotation and cannot be invoked in strict mode 
The problem appears to be traceable to the resolve definition in app.js because I can change the name of 'myDependency' there in the resolve and the error message uses the name from there rather than the name of the dependency in myCtrl. And I am explicitly listing the name of the dependency in the myCtrl controller. The app works, but I cannot minify this code because of the problem with this error.
Follow strict-di for resolve as well. Hope this works!
resolve : {
           myDependency : ['Cache', 'Model', '$route', function(Cache, Model, $route){ 
               return Cache.getCached( $route.current.params.userId); 
           } 
     ]}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With