1

可以像下面的代码一样在 $watch 中使用 $emit 吗?

    $scope.$watch("IsResponseArrived", function () {
        if ($scope.IsResponseArrived) {
            if ($scope.IsAuthorize) {
                var data FillData();
                $scope.$emit("DataResponse", { retVal: data });
            }
            else {
                reset();
            }
        }
    });

并且参数 IsResponseArrived 从脚本中更改如下:在 html 页面中,我有

<input type="text" id="cgResponseArrived" ng-model="IsResponseArrived" /> 
<input type="hidden" click="Fill()" /> 

<script> 
function Fill() { 
       $("#cgResponseArrived").val(true).trigger("change"); 
} 
</script> 

和其他一些请求被触发隐藏输入的点击事件

谢谢先进

4

0 回答 0