###angularjs異步設置Select選擇框的當前欄目爲默認值 htmlhtml
<div class="form-group"> <label class="col-sm-3 control-label no-padding-right ng-pristine ng-untouched ng-valid ng-binding" for="groupvalue" ng-change="gchange()" ng-model="selectGroup">更改組</label> <div class="col-sm-9"> <select style="float:left;width:83%" class=" ng-pristine ng-untouched ng-valid" ng-model="nggroup" ng-options="a.id as a.name for a in groups"> <!--<option value=""></option>--> </select> </div> </div>
angular:angularjs
$http.get('/api/v1.0/webs') .success(function (response) { $rootScope.groups = response.allgroup; $scope.groups = $rootScope.groups; }).error(function () { alert('獲取數據失敗'); });
//這裏是你要給出當前欄目id,能夠在html模板中給出groupid=12,而後在angularjs中取到: $scope.nggroup=groupid;
這裏是關鍵:$scope.nggroup 對應ng-model="nggroup"web