angularjs – 如何使用ngdoc来记录角度服务中的函数声明?
发布时间:2020-12-17 17:41:25 所属栏目:安全 来源:网络整理
导读:我想将ngdoc文档添加到角度服务中的函数声明中.我如何在下面的示例中为myFunction执行此操作? 我估计我需要像@closure,@ functionOf或@functionIn这样的东西. 请注意(与myMethod相反)myFunction不是一种方法. /** * @ngdoc service * @name myApp.service:m
我想将ngdoc文档添加到角度服务中的函数声明中.我如何在下面的示例中为myFunction执行此操作?
我估计我需要像@closure,@ functionOf或@functionIn这样的东西. 请注意(与myMethod相反)myFunction不是一种方法. /** * @ngdoc service * @name myApp.service:myService * @description * My application. */ angular .module('myApp') .factory('myService',function() { 'use strict'; var x = 0; /** * @ngdoc function * @name ? * @description * How can this be identified as being within the closure of * myService,and not be described as a constructor? */ function myFunction (z) { x++; x += z; } return { /** * @ngdoc method * @name myMethod * @methodOf myApp.service:myService * @description * A method of myService. */ myMethod : function (x) { myFunction(x); } }; }) 解决方法
您要查找的关键名是@methodOf注释.
当我使用grunt-ngdocs为服务编写文档时,它最终看起来如下所示: /** * @ngdoc overview * @name module * @description A small module containing stuff */ angular .module(module,[]) .factory('name',factory); /** * @ngdoc object * @name module.name * @description Its a pretty bad factory */ function factory() { return { doSomething: doSomething }; /** * @ngdoc function * @name module.name#doSomething * @methodOf module.name * @description Does the thing * @param {string=} [foo='bar'] This is a parameter that does nothing,it is optional and defaults to 'bar' * @returns {undefined} It doesn't return */ function doSomething(foo){...} } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |