angular.js - 关于ng-model和ng-bind的疑问
某草草
某草草 2017-05-15 16:53:53
0
3
584

双向绑定,一般来说是这样

<input ng-model="object.xxx">
<span ng-bind="object.xxx"></span>

也就是说ng-bind是相当于{{object.xxx}},是用于展示数据的。而ng-model是控制数据的。

但在这里,我从后台获取到设备号后,输出到页面,对input使用的是ng-model,使用ng-bind是没有反应的,为什么?

某草草
某草草

reply all(3)
黄舟
<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
習慣沉默

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().

Ty80

ng-bind is a one-way binding from $scope -> view
ng-modle is a two-way binding from $scope <-> view

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!