1

Is it ok to use $emit in $watch like this code below?

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

and the parameter IsResponseArrived changes from script like this: in html page I have

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

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

and some other request is triggered the click event of the hidden input

Thank you in advanced

user3132295
  • 288
  • 4
  • 23
  • Yes there is no problem of using that. – Shashank Agrawal Dec 31 '14 at 10:54
  • Thank you for youe answer, but if the parameter IsResponseArrived changes from script like this: in html page I have and some other request is triggered the click event of the hidden input – user3132295 Dec 31 '14 at 11:13
  • I suggest you put ^ in your question or post a new question – dcodesmith Dec 31 '14 at 11:15
  • [read this](http://stackoverflow.com/q/14994391/1139099) question before solving the problem – harishr Dec 31 '14 at 12:26

0 Answers0