Edit in JSFiddle

angular.module('app', []);

angular.module('app').controller('myController', [
    '$scope', 'myService',
    function($scope, myService) {
        myService.getUsers().then(function(users) {
            $scope.users = users; 
        });
    }
]);

(function() {
    function MyService($q) {
        this.$q = $q;
    };
    MyService.prototype.getUsers = function() {
        return this.$q.when([{login: 'login1'}]);
    }
    angular.module('app').service('myService', ['$q', MyService]);
})();