UI 路由器未将已解析的值注入同一级别的视图

UI Router is not injecting resolved value into views at the same level

我有以下状态配置:

$stateProvider
  .state('customer', {
    url: '/customers',
    templateUrl: 'app/components/customer/templates/main.tpl.html',
    views: {
      'list': {
        templateUrl: 'app/components/customer/templates/list.tpl.html',
        controller: 'ListCtrl as ctrl'
      }
    },
    resolve: {
      customerList: function ($stateParams, CustomerResource) {
        console.log('trying to resolve');
        var list = CustomerResource.list($stateParams);
        return list;
      }
    }
  })

这是主要模板:

<div class="container">
  <div class="row">
    <div ui-view="list" class="col-lg-4"/>

    <div ui-view="details" class="col-lg-8"/>
  </div>
</div>

我在控制台上看到 angular 正在尝试解决依赖关系。但是这种依赖永远不会注入到 views 下的控制器中。我在这里做错了什么?

P.S。当我将 views 移动到 customer.test 等子状态时,已解析的依赖项按预期注入:

 .state('customer.test', {
    url: '/test',
    views: {
      'list@customer': {
        templateUrl: 'app/components/customer/templates/list.tpl.html',
        controller: 'ListCtrl as ctrl'
      }
    }
  })

a working plunker

这里的问题不在于resolve,而在于主模板的注入。这应该是状态定义:

  .state('customer', {
    url: '/customers',
    //templateUrl: 'app/components/customer/templates/main.tpl.html',
    views: {
      '': { 
        templateUrl: 'app/components/customer/templates/main.tpl.html'
      },
      'list@customer': {
        templateUrl: 'app/components/customer/templates/list.tpl.html',
        controller: 'ListCtrl as ctrl'
      }
    },
    resolve: {
      customerList: function ($stateParams, CustomerResource) {
        console.log('trying to resolve');
        var list = CustomerResource.list($stateParams);
        return list;
      }
    }
  })

所以,在发挥这些作用时:

.controller('ListCtrl', ['$scope', 'customerList', function ($scope, customerList) { 
  $scope.resolved =  customerList
}])
.factory('CustomerResource', function(){
  return {
    list: function(params){return "Hello world"}
  }
})

我们可以看到这样的列表视图:

<div>
  <h3>list view</h3>
  {{resolved}}
</div>

会显示Hello world

检查一下here in action