我有一个选择框,我对其应用了角度选择。以下是完整的 HTML
<body ng-app="myApp">
<div ng-controller="mainController">
<div ng-init="init()">
<select id="selectid1" name="selectid1" ng-model="angularselect" chosen>
<option value=""></option>
<option ng-repeat="report in reportValuesOptions" value="{{report['value']}}">{{report['name']}}</option>
</select> Value : {{angularselect}}
</div>
<input type="button" ng-click="addreport()" value="Add Report" />
</div>
</body>
选择框正在从控制器范围内的数组中填充$scope.reportValuesOptions = [];
有一个init
函数在加载时调用以在框中div
设置默认值select
$scope.init = function()
{
$scope.reportValuesOptions.length = 0;
$scope.reportValuesOptions.push({'name':'Previous day compasite','value':'previousdaycomposite'});
$scope.reportValuesOptions.push({'name':'ACH Customer Activity','value':'achcustomeractivity'});
}
HTML中有一个在单击以在数组中添加值时button
调用该函数addReport
$scope.reportValuesOptions
但是单击此button
按钮时,添加到数组的值不会反映在select
框中。这些值也应该可以select
作为它的 boxoption