angularJS 从后台获取所有分类,并默认选中值(select)
1.html
<select name="parentColumnId" id="selectId" ng-select="mySelect">
<option ng-repeat="item in allFL" value="{{item.id}}" ng-selected="item.id==mySelect">{{item.columnName}}</option>
</select>
select 上设置ng-selected(被选中的值)
option选项中进行判断 当前的id跟被选中的id是否一致
2.js ===获取所有的分类
$http.get('http://192.168.1.107:8080/healthy/findAllFirstColumn.do')
.success(function(res){
console.log(res);
$scope.allFL = res;
}).error(function (err){
console.log(err);
})
3.===获取当前id的父分类
$http.get('http://192.168.1.107:8080/healthy/findColumnById.do?id='+$routeParams.id)
.success(function(res){
console.log(res);
$scope.info = res;
$scope.mySelect = res.parentColumnId;
}).error(function (err){
console.log(err);
})

浙公网安备 33010602011771号