Im am currently in the process of documenting my first real AngularJs app, for wich a am using ngdocs syntax with grunt-ngdocs
I was wondering if there is a better way to annotate that my service method returns a promise (so you know you should append a .then() instead of accessing the return object.
* @returns {object} returns a promise
Full context of the service:
/**
* @ngdoc service
* @name appServices.Authentication
* @requires $http
* @description
* Service used to authenticate request to an api. It injects a session parameter into each request if the token parameter is set.
* (as a request param for a GET and as an extra body param for a POST)
**/
module.factory('Authentication', ['$http', function ($http) {
var token;
/**
* @ngdoc method
* @name appServices.Authentication#login
* @methodOf ng.service
* @returns {object} returns a promise
*/
function login(email, password) {
return $http.post('/auth/login', {email: email, password: password})
.then(function (response) {
if (response.data.token) {
token = response.data.token;
}
});
}
function getToken() {
return token;
}
return {
login: login,
token: getToken,
};
}]);
You can simply write: