如何在不同状态之间使用AngularJS广播?

时间:2015-09-09 17:13:01

标签: javascript angularjs broadcast

我有函数editPrcChallenge我在哪里将用户路由到子状态并广播challengekey,广播正在调用但它不在函数内部,任何想法我已经实现了错误?

到目前为止尝试过代码......

parent.js

$scope.editPrcChallenge = function (challengeKey) {
    $scope.$broadcast('editPrcChallenge',challengeKey);
    $state.go('app.editChallenge',{processId:$stateParams.processId,challengeKey:challengeKey});
};

child.js

$scope.$on('editPrcChallenge', function (s,challengeKey){
    console.log(challengeKey);
    $scope.editMode = true;
    // $scope.clearFields = clearForm();
    processFactory.getProcessChallengeInfo(challengeKey)
        .then(function(response){
            $scope.challengesDTO =response.data;
            $scope.showEscalation = !!$scope.challengesDTO.challengeDesLkupCode;
        });
};

0 个答案:

没有答案