The input is the following:
<input type="text" ng-model="repair.test" ng-change="action()" />
The action()
is executed when I manually type and change the input. However if I change the repair.test value by some other function programmatically, it doesnt fire the ng-change's action. I have read the angular tutorial and it's probably the expected behavior.
https://docs.angularjs.org/api/ng/directive/ngChange
"The expression is not evaluated when the value change is coming from the model." <- I need this too.
How can I fire an action in controller, when the model changes in any way? (typing in input or by any other function)
Thanks for the help.
Edit:
The model value is actually the form.$valid
, which has it's own Form controller around it (I think), that is why I used the action function to try to pass the value to the parent controller. So $scope.$watch
at the moment doesn't work, only when it is initialised.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…