Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在$watch angularjs中使用$emit可以吗_Angularjs_Watch_Emit - Fatal编程技术网

在$watch angularjs中使用$emit可以吗

在$watch angularjs中使用$emit可以吗,angularjs,watch,emit,Angularjs,Watch,Emit,可以像下面的代码那样在$watch中使用$emit吗 $scope.$watch("IsResponseArrived", function () { if ($scope.IsResponseArrived) { if ($scope.IsAuthorize) { var data FillData(); $scope.$emit("DataResponse", { retVal:

可以像下面的代码那样在$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> 
其他一些请求会在隐藏输入的单击事件中触发


高级版谢谢你

是的,使用它没有问题。谢谢你的回答,但是如果参数是ResponseArrived,那么脚本的更改如下:在html页面中,我有函数Fill{$cgResponseArrived.valtrue.triggerchange;}当隐藏输入的单击事件触发其他请求时,我建议您在问题中添加“^”,或在解决问题之前发布新问题