Whenever I call the Details function, it returns empty details because the function executes before retrieving data from the json file. What is the best way to fix this issue?
app.controller('loginCtrl',function($scope,login){
$scope.user=login.Details();
}
app.factory('login',function($cookieStore,$http){
var users=[];
$http.get("js/user.json").success(function(data){
angular.copy(data,users);
});
return{
Details:function()
{
alert(users);
return users;
}
}