I have started to learn something about AngularJS. I managed to create some simple controllers, but I would like to do a bit of refactoring and create also a factory.
Here is one of my js files:
angular
.module('myApp', ['ngResource'])
.factory('UserFactory', ['$http', function ($http) {
    return {
        getOne: function () {
            $http({method: 'GET', url: 'http://localhost:8080/login/login'})
                .success(function (data, status, headers, config) {
                    console.info(data);
                    return data;
                })
                .error(function (data, status, headers, config) {
                    alert("failure");
                });
        }
    }
}])
.controller('UserController', ['$scope', 'UserFactory', function ($scope, UserFactory) {
    $scope.user = UserFactory.getOne();
}]);
The program correctly prints the data to the console received from the servlet at that line: console.info(data);
But the controller does not return anything to the view. I put here also console.info(UserFactory.getOne()) and it prints undefined.
Where is my coding mistake?
 
     
     
    