When I am calling Details function it is giving empty details because Details function is executing before getting the data from the json file. How to resolve the problem?
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;
    }
}
 
     
    