任意の配列にselect基づいています。配列内の要素は変更される場合があります。angularコントローラーでアレイをリフレッシュするにはどうすればよいですか?
module.js
var langMod = angular.module('langMod', []);
langMod.controller( .controller( 'colorCntl', function($scope) {
$scope.color = 'wt';
$scope.colorArr = [
{ id: 'br', name: '茶色' },
{ id: 'wt', name: '白' }
];
});
index.html
<form ng-controller='wordCntl' >
<select ng-model="color" ng-options="c.id as c.name in colorArr の c ">
<option value=''>-- 色を選択 --</option>
</select>
</フォーム>
コンソールから:
> スコープ = angular.element(document.querySelector('select')).scope();
> scope.colorArr.push( { id:'bk', name:'black' } );
3
ノート!選択ドロップダウンにはまだ黒ではなく茶色と白しかありません
selectすべての要素colorArrがオプションになるように更新するにはどうすればよいですか?