Two-way binding, generally speaking is like this
<input ng-model="object.xxx">
<span ng-bind="object.xxx"></span>
In other words, ng-bind is equivalent to {{object.xxx}}
, which is used to display data. And ng-model controls data.
But here, after I get the device number from the background, I output it to the page. I use ng-model for input, but there is no response when using ng-bind. Why?
黄舟2017-05-15 16:55:53
<input type="text" ng-value="object.xxx" readonly="readonly" />
http://stackoverflow.com/a/12420157/2586541
$('#input1').html('123'); //ng-bind
$('#input1').val('123'); //ng-value
習慣沉默2017-05-15 16:55:53
How did you obtain the device number?
If you implement ajax yourself, you need to manually $scope.$apply();
after getting the data
If $http is used to obtain data, angular will automatically call $apply().
PHP中文网2017-05-15 16:55:53
ng-bind is a one-way binding from $scope -> view
ng-modle is a two-way binding from $scope <-> view