Javascript 如何在angular中使用ngdoc记录factory函数创建的对象?
如何使用ngdoc记录返回“工厂函数”的“角度工厂”?具体来说,如何记录“工厂功能”创建的对象 在下面的人为示例中,我记录了如何使用工厂创建页面对象,但如何记录如何使用页面对象本身Javascript 如何在angular中使用ngdoc记录factory函数创建的对象?,javascript,angularjs,factory,ngdoc,Javascript,Angularjs,Factory,Ngdoc,如何使用ngdoc记录返回“工厂函数”的“角度工厂”?具体来说,如何记录“工厂功能”创建的对象 在下面的人为示例中,我记录了如何使用工厂创建页面对象,但如何记录如何使用页面对象本身 angular.module('fooRestClient').factory('page', function () { var prototype = {}; // Below I need to somehow link the methods a page object has to the
angular.module('fooRestClient').factory('page', function () {
var prototype = {};
// Below I need to somehow link the methods a page object has to the
// factory's documentation.
/**
* @description Fetches the page at the specified index.
*
* @param {number} index - the index of the page to fetch
*
* @returns {object} a page object representing the page at the given index
*/
prototype.getPage = function (index) {
// returns a new page.
};
// ... more useful methods.
/**
* @ngdoc service
* @type function
* @name fooRestClient:page
* @description
* A factory function for producing page objects....
*
* @param {Number} index - The page index.
* @param {Number} size - The page size.
* @param {Number} total - The total number of pages.
* @param {Array} data - The contents of the page.
* @returns {object} A page object for the given resource
*/
return function page(index, size, total, data) {
return Object.create(prototype, {
index: index,
size: size,
total: total,
data: data
});
};
});
我能在SO上找到的最接近的匹配项是:。这没有帮助,因为我没有“类”名称来链接方法,因为我没有使用伪经典继承 也许这会像你期望的那样起作用:
/**
*@ngdoc服务
*@type函数
*@name fooRestClient:page
*@说明
*用于生成页面对象的工厂函数。。。。
*
*@param{Number}索引-页面索引。
*@param{Number}size-页面大小。
*@param{Number}total-总页数。
*@param{Array}data-页面的内容。
*@返回给定资源的{object}A{@link prototypeInstance | page object}
*/
返回函数页(索引、大小、总数、数据){
/**
*@ngdoc对象
*@name原型实例
*@给定资源的说明页对象
*/
返回Object.create(prototype{
/*
*@ngdoc对象
*@name原型实例#索引
*@description索引description
*/
索引:索引,,
/*
*@ngdoc对象
*@name原型实例#大小
*@description大小description
*/
尺寸:尺寸,
/*
*@ngdoc对象
*@name原型实例#总计
*@description总计description
*/
总计:总计,
/*
*@ngdoc对象
*@name原型实例#数据
*@description数据描述
*/
数据:数据
});
};代码>