I'm using angularjs with asp.net mvc. On my page, I have 5 dropdown lists, all populated with values from different database tables. In order to retrieve the data for all dropdowns, I'm making 5 different $http.get requests, which makes my page load time slow to a crawl. I know this is setup wrong, but not sure how to do it properly. Here's my angular code, which makes a call to an mvc action, returns the values for the dropdown & passes the results into the $scope, for the dropdown to display:
var CustomSearchController = function ($scope, $http) {
$http.get('/Account/GetLists')
.success(function (result) {
$scope.listDetails = result;
})
};
$http.get('/Account/GetGenders')
.success(function (result) {
$scope.genderDetails = result;
})
};
$http.get('/Account/GetEthnicities')
.success(function (result) {
$scope.ethnicityDetails = result;
})
};
$http.get('/Account/GetRegions')
.success(function (result) {
$scope.regionDetails = result;
})
};
$http.get('/Account/GetAcademics')
.success(function (result) {
$scope.academicDetails = result;
})
};
What's the correct way to go about this?