Sunday 15 March 2015

javascript - Why does my $watch only ever fire once? -


I'm fitting some widgets and the $ watch expression works perfectly in a file But now I took a new controller and markup into a new controller in a new controller and after the initialization, I set a fire at $ watch once, but when editing the typing in related input No.

= Function (input) {Console.log ("detected change")} $ scope. $ Watch ("addressInput", testReceivingAddress)}]

Wrapper HTML:

  & lt; Ng- included src = "'partial / getRecipientWidget.html'" ng-controller = "getRecipientWidgetController" ng-init = "recipient = certificate" & gt; & Lt ;! - NG-Init does not affect the bug. - & gt; & Lt; / Ng-included & gt; HTML of  partial / getRecipientWidget.html  

  & lt; Md-text-float ng-model = "addressInput" HTML  

& gt; & Lt; / MD-text float & gt;

I suspect that there is some chance magic? I have left ng-init to make it clear: To create a clearly more complex, reusable widget which in this example is $ scope.cert < / Code> will work on its recipient .

This is because ng-include contains a new legacy radius on HTML , So your controller does not have the same reference as $ scope.addressInput as the $ code = $ scope.addressInput . GetRecipientWidget.html

It's not easy to explain, but keep you within the HTML of ng-controller getRecipientWidget.html (And not included above), or you can use an object like some.addressInput instead of raw addressInput , which is the reference problem on raw types Avoids (number / string).


No comments:

Post a Comment