ui-router-extras
ui-router-extras copied to clipboard
uglification: Unknown provider: $futureStateProviderProvider
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
}
},
@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.
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?
@critical Look at the first line, it seems you are missing to annonate futureState inline.
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
I resolved the problem. It was a my fault. Many thanks.