我有两个嵌套状态,由父抽象状态和子状态组成:
.state('app.heatingControllerDetails', {
url: "/clients/:clientId/heatingControllers/:heatingControllerId",
abstract: true,
views: {
'menuContent': {
templateUrl: "templates/heatingController.html",
controller: 'HCDetailsCtrl'
}
}
})
.state('app.heatingControllerDetails.wdc', {
url: "/wdc",
views: {
'hc-details': {
templateUrl: "templates/heatingControllers/wdc.html",
controller: 'WdcDetailsCtrl'
}
},
resolve:{
hcFamily: [function(){
return 'wdc';
}]
}
})
和两个 Controller 是:
.controller('HCDetailsCtrl',function($scope){
$scope.$on("$ionicView.enter", function (scopes, states) {
...
});
})
.controller('WdcDetailsCtrl',function($scope){
$scope.$on("$ionicView.enter", function (scopes, states) {
...
});
})
当我调用 state app.heatingControllerDetails.wdc 时,两个 Controller 都被创建,但 $ionicView.enter 只在父 Controller 上被调用。任何的想法?
在heatingController.html中,hc-details View 定义如下:
<ion-content class="has-header" ng-show="hc">
<div ui-view name="hc-details"></div>
<div class="disableContentDiv" ng-hide="hc.state=='Online'"></div>
</ion-content>
最佳答案
使用嵌套 View 时,您必须使用 $ionicNavView
事件而不是 $ionicView
话虽如此,在上一个版本中,这些事件已被窃听,目前正在修复中:Github issue
关于state - ionicView.enter 未在 subview 及其 Controller 上触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30097626/