0
我想動態更改使用Angular JS的下拉列表控件的選擇項,但它不會更改視圖。 我試過this one,但還沒有結果!AngularJS:動態更改下拉列表控件的選擇項使用
控制器:
$scope.dischargeType = {id:0,title:''};
$scope.setSelect = function() {
debugger;
$scope.dischargeType = $scope.dischargeTypes[1];
alert($scope.dischargeType.title);
// it shows that the $scope.operationType get the value,but no changes on html
}
查看:
<label class="col-sm-3 control-label">Discharge Type</label>
<div class="col-sm-9">
<select ui-select2 data-ng-model="dischargeType" id="add-dischargeType" name="dischargeType">
<option data-ng-repeat="item in dischargeTypes" value="{{item.id}}">{{item.title}}</option>
</select>
</div>
謝謝確實如此。
我已經刪除了調用函數的代碼。 – Discover
函數setSelect()使用html中的按鈕調用,並且警報正在提升並顯示我期望的值。在我的控制檯中沒有錯誤。 – Discover