javascript - Angular $watch not triggered on field modifed by popup -
i have angular 1.4.x app launches popup window (for oauth stuff). @ point popup write value input field on main parent window/app. process works fine. have app run code once field updated seems when field updated popup $watch function never triggered. if put cursor in field , modify value works fine. issue?
the input field:
<input type="text" id="url" ng-model="item.url">
the controller watch bit:
$scope.$watch('item.url', function(n, o) { console.log(n, o); });
the popup code writes parent:
var url = window.opener.document.getelementbyid("url").focus(); url.value = "hello";
note don't care if use input field - open other methods. need pass value angular app in simple manner (i.e. basic cross browser code without libs) , have go there - seems straightforward way.
try piece of code:
var opener = window.opener; //replace 'controller-id' id of controller div var controllerdiv = opener.document.getelementbyid('controller-id'); var scope = opener.angular.element(controllerdiv).scope(); scope.title= 'hello'; //we update scope manually, have call scope.$digest();
Comments
Post a Comment