This is my factory and in my factory http call I am assigning value to my User variable but it is not updating my controller.
mainApp.factory('AccountFactory', ['$http', function ($http) {
var User = {
};
function getLogOnModel() {
$http.get("http://localhost/mylocalspecial/Account/LogOn").then(function (data) {
User = data.data;
alert(JSON.stringify(data.data));
return data;
});
}
// Init model (or leave it for the controller to init it)
getLogOnModel();
return {
User: User,
getLogOnModel: getLogOnModel
};
}]);
This is my controller as you can see in my controller I am assigning factory User variable to $scope.logOnModel but my controller is not updating.
mainApp
.controller('AccountController', ['$scope', 'AccountFactory',
'AuthenticationServiceFactory'
, function ($scope, AccountFactory,
AuthenticationServiceFactory) {
$scope.logOnModel = {};
$scope.customerModel = {};
$scope.logOnModel = AccountFactory.User;
alert(JSON.stringify(AccountFactory.User));
}]);