gpt4 book ai didi

javascript - 如何为 Angular 组件注释 ngdoc?

转载 作者:可可西里 更新时间:2023-11-01 01:54:49 30 4
gpt4 key购买 nike

我正在编写一个 AngularJS 组件,我想知道将 ngdoc 注释添加到组件本身和 Controller 函数的正确方法是什么。

你有什么例子吗?

最佳答案

这里有一个例子:

controller.js::

/**
* @this vm
* @ngdoc controller
* @name dragDropRelation.controller:draggableItemController
*
* @description
* Controller for the draggableItem component
*/
export default function draggableItemController() {

}

组件.js:

import controller from './controller.js';
import templateUrl from './view.html';
/**
* @ngdoc component
* @name dragDropRelation.component:draggableItem
*
* @description
* Component that allows to be dragged containing some data.
* @param {Boolean} used Used flag
*
* @param {String} text Text to display
* @param {Object} data Data to be saved
*
* @param {Boolean} disabled variable to disable the component
*/
export const component = {
templateUrl: templateUrl,
controller: controller,
bindings: {
used: '<?',
text: '<',
data: '<',
disabled: '<?',
},
};

module.js:

import angular from 'angular';
import angularDragDrop from 'angular-drag-drop';
import {component} from './component.js';


/**
* @ngdoc overview
* @name dragDropRelation.module:draggableItem
*
* @description
* Module that contains the component draggableItem
*
* @example
* <b>script.js</b>
* <pre>
* import draggableItem from
* './components/drag-drop-relation/draggable-item/module'
* angular.module('myModule', [draggableItem]);
* </pre>
*
*/
export default angular
.module('draggableItem', [angularDragDrop])
.component('draggableItem', component)
.name;

这将生成如下内容(使用 gulp-ngdocs):

NGDocs(我的原始组件的文档是西类牙语)

关于javascript - 如何为 Angular 组件注释 ngdoc?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39189658/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com