ui-templateUrl 的路由器缩小?

ui-router minification of templateUrl?

我有这个代码:

.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;
        }]
    };

我做了我认为需要做的事情,以便在缩小时完成这项工作,但似乎 AngularJS 无法解析 $stateParams

有没有人遇到过类似的问题?

templateUrl 属性 接受字符串或函数,函数只接受一个参数,即 toParams - 它不支持可注入参数。

在你的情况下,直接分配函数而不用数组:

.state("access", {
   // ...
   templateUrl: function(toParams){
      var page = 'app/access/partials/' + toParams.content + '.html';
      return page;
   }
});