如何在文档中描述angular控制器方法



我无法描述控制器的方法。我怎么能做到呢?

/**
* @ngdoc controller
* @name works.controller:worksCtrl
* @requires $http
* @requires $element
* @function
*
* @description
* Description for works controller. All methods will be writen later
*/
var worksCtrl = function ($http, $element) {
    var ctrl = this;
    //how it do there? this not work
    /** 
        * @name initializeGrid
        * @function
        * @description
        * Description for initializeGrid
    */
    ctrl.initializeGrid = function (a) {
       //...
    }
    ctrl.getTemplate = function (workIndex) {
      //...
    }
    //...
};

我使用ngdoc自动生成文档。但是我不明白我做错了什么。

我从来没有使用过ngdoc,但是看看angular代码本身,看起来你需要在文档中添加一个@ngdoc method标签来实现内部函数。例如,在$locationProvider中:

  /**
   * @ngdoc method
   * @name $locationProvider#hashPrefix
   * @description
   * @param {string=} prefix Prefix for hash part (containing path and search)
   * @returns {*} current value if used as getter or itself (chaining) if used as setter
   */
  this.hashPrefix = function(prefix) {
    if (isDefined(prefix)) {
      hashPrefix = prefix;
      return this;
    } else {
      return hashPrefix;
    }
  };
/**
* @ngdoc function
* @name initializeGrid
* @methodOf works.controller:worksCtrl
* @description This method initialize auto grid system for works
* @private
*/
ctrl.initializeGrid = function () {
     ...
}

最新更新