Ui-router minification templateUrl?
I have this code:
.config(
['$locationProvider', '$sceDelegateProvider', '$sceProvider', '$stateProvider', function ($locationProvider, $sceDelegateProvider, $sceProvider, $stateProvider) {
var access = {
name: 'access',
url: '/Access/:content',
templateUrl: ['$stateParams', function ($stateParams) {
var x = $stateParams;
var page = 'app/access/partials/' + $stateParams.content + '.html';
return page;
}]
};
I did what I thought it took to make this work when it was minified, but it looks like AngularJS cannot resolve $stateParams
.
Has anyone faced a similar problem?
+3
source to share
1 answer
templateUrl
property takes a string or function and the function only takes one parameter which is toParams
- it doesn't support injection parameters.
In your case, assign the function directly without an array:
.state("access", {
// ...
templateUrl: function(toParams){
var page = 'app/access/partials/' + toParams.content + '.html';
return page;
}
});
+4
source to share