I am facing an issue where my $http.get() request is firing after the home page has already loaded. How can I ensure that the request fires before the page loads so I can utilize the returned data on the page?
Here is a snippet of the routing code:
var leisureApp = angular.module('leisureApp', ["ngRoute"]);
leisureApp.config(["$routeProvider", "$locationProvider",
function ($routeProvider, $locationProvider) {
// route configurations here
}]);
HomeController:
angular.module('leisureApp')
.controller('HomeController', ['$scope', 'ADAuth', function ($scope, ADAuth) {
$scope.ADAuth = ADAuth;
}])
.factory('ADAuth', function ($http) {
return $http.get('Home/GetUser');
})
MVC Controller method:
public JsonResult GetUser()
{
// controller logic here
}
Any suggestions or tips on how to resolve this issue would be greatly appreciated.