ui-router-extras icon indicating copy to clipboard operation
ui-router-extras copied to clipboard

uglification: Unknown provider: $futureStateProviderProvider

Open temp3l opened this issue 9 years ago • 5 comments

Unknown provider: $futureStateProviderProvider <- $futureStateProvider <- $futureState

Please help! this code works fine, but fails with the above error after minification:

I tried this with a fresh yeoman build of angular-fullstack and added the following code:

angular.module('futureApp', [
    'ngResource',
    'ui.router',
    'ct.ui.router.extras',
    'ct.ui.router.extras.future'
    ])
.config(['$futureStateProvider', function($futureStateProvider) {
    var loadAndRegisterFutureStates = function ($http) {
        return $http.get("future.js").then(function (resp) {
            $futureStateProvider.futureState( {
                "stateName": "iframe2",
                "urlPrefix": "/iframe2",
                "type": "iframe",
                "src": "/someHtml.html"
            });
        });
    };
    $futureStateProvider.addResolve(loadAndRegisterFutureStates);
}])

Updating to grunt-ng-annotate to 1.0.2 did not help me! updated all my packages in package.json to latest version

Even tried injection like this:

loadAndRegisterFutureStates.$inject = ['$futureStateProvider'];

I have to disable mangling to make it work ;(

 uglify: {
        options: {
            report: 'min',
            mangle: false
        }
    },

temp3l avatar Oct 27 '15 19:10 temp3l

@stephanMettler I was running into the same issue and found out that if I am using $futureStateProvider.addResolve, the function passed works just fine if it is inline annotated. i.e. $futureStateProvider.addResolve(['$http', '$log', function ($http, $log) { }]) and then the minification worked just fine. Also, do make sure that your $futureStateProvider.stateFactory is also inline annotated just like I mentioned for addResolve.

nkanand4 avatar Nov 13 '15 23:11 nkanand4

Hi @nkanand4, I have the same issue during uglify when I try to add a state factory with the following code

$futureStateProvider.stateFactory('ocLazyLoad', ['$q', '$ocLazyLoad', function($q, $ocLazyLoad, futureState) {  
  var deferred = $q.defer();  
  $ocLazyLoad.load(futureState.module).then(function(name) {
      deferred.resolve();
     }, function() {
      deferred.reject();
    }
  );
  return deferred.promise;
}]);

The error is Cannot read property 'module' of undefined because the parameter futureState is undefined. What am I doing wrong?

fabiogomiero avatar May 15 '16 18:05 fabiogomiero

@critical Look at the first line, it seems you are missing to annonate futureState inline.

nkanand4 avatar May 15 '16 19:05 nkanand4

Yes because futureState is the parameter passed by ui-router-extras (line 1435). I can't inject this value. I'm using angular v.: 1.5.5, ui-router v.: 0.2.18 and ui-router-extras v.: 0.1.2. Any ideas? Thank you @nkanand4

fabiogomiero avatar May 16 '16 06:05 fabiogomiero

I resolved the problem. It was a my fault. Many thanks.

fabiogomiero avatar May 19 '16 21:05 fabiogomiero