首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法构建angularjs (不知道如何格式化@ngdoc:方法)

无法构建angularjs (不知道如何格式化@ngdoc:方法)
EN

Stack Overflow用户
提问于 2014-05-12 20:09:50
回答 2查看 7.8K关注 0票数 11

我有一个带有一些文档的服务,但是当我尝试使用grunt-ngdocs构建文档时,它会失败:

代码语言:javascript
复制
Warning: Don't know how to format @ngdoc: method Use --force to continue.

这就是我想要做的

代码语言:javascript
复制
(function(angular) {
    'use strict';

    angular.module('services.base64', [])
    .factory(
            'Base64',
            [function() {

                /**
                 * @ngdoc service
                 * @name Base64
                 * @module services.base64
                 * @description Provides encoding a string into base64, and decode base64 to a string
                 */
                return {
                    /**
                     * @ngdoc method
                     * @name Base64#encode
                     * @param {string}
                     *            input the string you want to encode as base64
                     * @returns {string} the base64 encoded string
                     */
                    encode : function(input) {
                        //...
                    },

                    /**
                     * @ngdoc method
                     * @name Base64#decode
                     * @param {string}
                     *            input the base64 encoded string
                     * @returns {string} the decoded string
                     */
                    decode : function(input) {
                        //...
                    }
                };
            }]);
}(angular));

我肯定我错过了一些简单的东西..。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-05-23 18:49:53

以下是我最后所做的

代码语言:javascript
复制
(function(angular) {
    'use strict';

    /**
     * @ngdoc overview
     * @name services.base64
     */
    angular.module('services.base64', [])
    .factory(
            'Base64',
            [function() {

                /**
                 * @ngdoc service
                 * @name services.base64.Base64
                 * @description Provides encoding a string into base64, and decode base64 to a string
                 */
                return {
                    /**
                     * @ngdoc method
                     * @name encode
                     * @methodOf services.base64.Base64
                     * @param {string}
                     *            input the string you want to encode as base64
                     * @returns {string} the base64 encoded string
                     */
                    encode : function(input) {
                        //...
                    },

                    /**
                     * @ngdoc method
                     * @name decode
                     * @methodOf services.base64.Base64
                     * @param {string}
                     *            input the base64 encoded string
                     * @returns {string} the decoded string
                     */
                    decode : function(input) {
                        //...
                    }
                };
            }]);
}(angular));

这似乎是我所做的

票数 11
EN

Stack Overflow用户

发布于 2014-08-25 19:08:44

问题正在发生,因为您需要给您的方法一个适当的父(服务、对象等)。因为您试图在函数返回语句上设置父services.base64.Base64,所以没有正确设置它。一旦将注释块移动到函数中,它就能够被正确地解释为方法父级,并随后工作。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23617961

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档