小编Gre*_*dic的帖子

ionicView.enter未在子视图及其控制器上触发

我有两个嵌套状态,由父抽象状态和子状态组成:

.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';
                    }]
                }
            })
Run Code Online (Sandbox Code Playgroud)

和两个控制器是:

   .controller('HCDetailsCtrl',function($scope){
        $scope.$on("$ionicView.enter", function (scopes, states) {
        ...
        });
     })
    .controller('WdcDetailsCtrl',function($scope){
        $scope.$on("$ionicView.enter", function (scopes, states) {
        ...
        });
     })
Run Code Online (Sandbox Code Playgroud)

当我调用状态app.heatingControllerDetails.wdc时,会创建两个控制器,但仅在父控制器上调用$ ionicView.enter.任何的想法?

在heatingController.html中,hc-details视图定义如下:

<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>
Run Code Online (Sandbox Code Playgroud)

state ionic ionic-view

7
推荐指数
1
解决办法
2850
查看次数

标签 统计

ionic ×1

ionic-view ×1

state ×1