0
Im与Anuglar有问题。 ng-bind
一旦它的值被用户输入改变,它就不会更新textarea。Angular - 在用户输入后不能更新textarea
注意:使用ng-bind代替ng模型的原因是我需要ng-bind-html
作为输入在html中使用ngSanitize
进行sanatized。
演示: http://jsfiddle.net/Lvc0u55v/11682/
这里是如何看什么即时通讯谈论:在下拉菜单和文本区域选择anyvalue被更新。但是选择New Value
并在textarea中放置一些文本。然后将选择框更改为任何值,并且textarea再也不会更改!
代码:
[SCRIPT]
$scope.msg_templates = []; //array of {id, title, msg} filled with required stuff
$scope.msg_templates[0] = {id:'0', title:'{New Value}', msg:''}; //first item is to enter new value
$scope.msg_templates[1] = {id:'1', title:'TTT', msg:'TTT'};
$scope.msg_templates[2] = {id:'2', title:'XXX', msg:'XXX'};
.
.
//set default value
$scope.msg_sel = '';
$scope.msg_field = '';
//change msg function
$scope.change_msg_sel = function()
{
if($scope.msg_sel==null){
$scope.msg_field = '';
return false;
}
$scope.msg_field = $scope.msg_sel.msg;
};
[HTML]
<select ng-model="msg_sel" ng-change="change_msg_sel()" ng-options="v.title for v in msg_templates">
<option value="">Please Select -</option>
</select>
<textarea ng-bind-html="msg_field"></textarea>
是msg_templates''v.title乞伏故意或者它想使用'comm_templates'?你应该使用'
其实际的'msg_templates',忘记在这里为这个例子重命名它。 –
适合我[jsfiddle](http://jsfiddle.net/0yoxpd11/1/)。我的小提琴中唯一不同的是,我从'
>'中删除了包装'ngApp',因为在另一个中不能包含'ng-app'。你知道'$ scope.msg_templates [0]'有一个空白的'msg',所以当选择什么都不会显示。 – user2718281