When I type some string to input element directly, two-way data binding of AngularJS works very well. But when I change value of input element by javascript code, two-way binding does not work. Is there a good way for doing this?
html code:
<div ng-app ng-controller="Ctrl">
<input id="inputElem" ng-model="modelName" type="text"/>
<span>{{modelName}}</span>
</div>
javascript code:
function Ctrl($scope) {
$scope.modelName = "";
}
function foo() {
// THIS DOES NOT TRIGGER ANGULAR DATA-BINDING!!!!
$("#inputElem").val("THIS IS DOM MANIPULATION");
}