我有Web API,它返回响应对象中的数据集。从AngularJS服务调用Web API。从另一个角度控制器调用服务功能。如何使用返回的响应对象中的数据表绑定下拉列表?
以下是我的代码:
Web API
public object getChallengeFilterData(JObject data)
{
MatchBAL matchBAL = new MatchBAL();
DataSet dsSeries= matchBAL.getChallengeFilter();
return successResponse(dsSeries);
}
controller.js
angular.module("myapp").controller("challengesController", ['$scope', 'challengesService', function ($scope, challengesService) {
$scope.MatchList = [];
$scope.SeriesList = [];
$scope.SelectedMatchId = "0";
$scope.SelectedSeriesId = "0";
function init() {
//$scope.getPlayersList();
$scope.getMatchList();
}
$scope.getMatchList = function () {
$scope.MatchList = [];
challengesService.getChallengeFilterData().then(function (response) {
$scope.SeriesList = response.data[0];
$scope.MatchList = response.data.data[1];
});
}
init();
}]);
HTML页面
<select class="form-control" ng-model="SelectedMatchId">
<option value="0">Select Match</option>
<option ng-repeat="option in MatchList" value="{{option.MatchId}}">{{option.MatchName}}</option>
</select>