我从查询中携带选择器到Web服务,在此我没有问题。但我需要加载一个默认值,例如"选择值"什么的,但我无法得到。我留下了我的代码
<select ng-model="datas.selectedVal" ng-change="update()">
<option value="{{org.id}}" ng-repeat="org in organizations">{{org.name}}</option>
</select>
控制器:
$http({method: 'GET', url: URL_BASE+'getOrganizations/'+sessionService.get("user_id")+'/'+sessionService.get("hash")+"/"})
.success(function(data){
if(data.Count > 0){
$scope.organizations = data.Organization;
}
})
.error(function(){
//console.log("Error en la conexion al Servidor")
})
.finally(function(){
$scope.hide();
});
答案 0 :(得分:0)
试试
<select ng-model="datas.selectedVal" ng-change="update()">
<option value=""> Select Value </option>
<option value="{{org.id}}" ng-repeat="org in organizations">{{org.name}}</option>
</select>
请使用ng-options代替ng-repeat选择框。 https://docs.angularjs.org/api/ng/directive/ngOptions
答案 1 :(得分:0)
试试这个兄弟:)
<select ng-model="datas.selectedVal" ng-options="org.id as org.name for org in organizations"></select>