have an select
based on any array. the elements in the array may change. how do I get the angular controller to refresh the array?
module.js
var langMod = angular.module('langMod', []);
langMod.controller( .controller( 'colorCntl', function($scope) {
$scope.color = 'wt';
$scope.colorArr = [
{ id: 'br', name: 'brown' },
{ id: 'wt', name: 'white' }
];
});
index.html
<form ng-controller='wordCntl' >
<select ng-model="color" ng-options="c.id as c.name for c in colorArr">
<option value=''>-- chose color --</option>
</select>
</form>
from the console:
> scope = angular.element(document.querySelector('select')).scope();
> scope.colorArr.push( { id:'bk', name:'black' } );
3
note! the select dropdown still only has brown and white, not black
how do I get the select
to refresh so that all elements in colorArr
are options?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…