Given an angular app with a factory that returns a class, as such:
angular.module('fooApp').factory('User', function(){
function User(name){
this.name = name;
}
User.prototype.greet = function(){
return "Howdy, " + this.name;
}
return User;
});
Using ngdoc
(the special flavor of jsdoc
angular uses), how do I document the initializer without defining it as a method?
Right now, this is what I've tried:
/**
* @ngdoc service
* @name fooApp.User
* @description User factory.
*/
angular.module('fooApp').factory('User', function(){
/**
* @ngdoc method
* @methodOf fooApp.User
* @name Initializer
* @description Initializes a new User object with a name
*/
function User(name){
this.name = name;
}
User.prototype.greet = function(){
return "Howdy, " + this.name;
}
return User;
});
But this results in the User
initializer (the User
function that accepts the parameter name
) being treated like a method with the name Initializer
, which is confusing to people trying to use this code.
I've tried adding the @constructor
flag, but this has no effect of the html .dgeni
ends up generating
Thank you.
UPDATE: Removed references to dgeni
. I was under the impression that the plugin I was using (grunt-ngdocs) uses dgeni
behind the scenes, but this is not the case.
This is how I would do it not having any experience with Angular in particular: