state - ionicView.enter 未在 subview 及其 Controller 上触发

标签 state ionic ionic-view

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

.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/

相关文章:

css - ionic : Custom ion list items

ionic-framework - Ionic Framework - 上传到 Ionic View 应用程序,没有获取最新的 javascript 文件,可能缓存仍然存在?

javascript - React JS : Rendered fewer hooks than expected. 这可能是意外提前返回语句导致的

macos - os x进程状态UE

angularjs - 无法让 `ion-nav-view` 工作

polymer 与 ionic 移动应用程序?

http - ionic View - 对预检请求的响应未通过访问控制检查 : No 'Access-Control-Allow-Origin' header

javascript - 如何使用 setState 更新 state.item[1]?

angularjs - 使用 stateProvider angularjs 的具有多个可选参数的 URL

ios - 在真实 ios 设备上测试时, ionic 推送通知错误 500