angularjs异步设置Select选择框的默认值

###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

相关文章
相关标签/搜索