2

我无法描述控制器方法。我怎么能这样做?

/**
* @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 来自动生成文档。但我不明白我做错了什么。

4

2 回答 2

4
/**
* @ngdoc function
* @name initializeGrid
* @methodOf works.controller:worksCtrl
* @description This method initialize auto grid system for works
* @private
*/

ctrl.initializeGrid = function () {
     ...
}

That is what i need.)

于 2015-07-18T13:22:14.770 回答
4

我从未使用过 ngdoc,但在寻找角度代码本身时,看起来您需要@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;
    }
  };

我希望它有所帮助。

于 2015-07-18T08:05:19.530 回答