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