Anuglarに問題があります。 ng-bind
ユーザ入力によってその値が変更されると、テキストエリアが更新されません。ユーザー入力後の角度 - カンタン更新テキストエリア
注:ng-modelではなくng-bindを使用している理由は、ngSanitize
を使用して入力がhtml sanatizedになっているため、ng-bind-html
が必要です。
デモ: http://jsfiddle.net/Lvc0u55v/11682/
ここ話してイム何を確認する方法である:ドロップダウンとテキストエリアから選択anyvalueが更新されます。しかし、New Value
を選択し、テキストエリアにテキストを入力します。選択ボックスを任意の値に変更すると、テキストエリアは決して再び変更されません!
コード:
[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のための 'v.titleであるか、それは' comm_templates'を使用していると仮定しているのですか?そして、実際に 'msg_templates'という'
の代わりに'
私のためにうまく動作します[jsfiddle](http://jsfiddle.net/0yoxpd11/1/)。私のフィドルの違いは、 'ng-app 'を他のものの中に置くことができないので、' ngApp'を '
'から取り除いただけです。 '$ scope.msg_templates [0]'には空白があり、何も選択されていなければ何も表示されません。 – user2718281