【问题标题】:Usage of ngdocs with controller properties in angularJS在angularJS中使用带有控制器属性的ngdocs
【发布时间】:2016-04-04 13:16:48
【问题描述】:

我刚刚开始在我的 Angular 应用程序中使用 grunt-ngdocs,到目前为止一切都很好。

但我现在想在我的一个控制器中记录另一个已记录属性的一些属性。

考虑以下代码:

(function() {
  'use strict';
  /**
   * @ngdoc controller
   * @name app.mymodule.controller:MyController
   * @description
   * A Controller
   */
  angular
      .module('app.mymodule')
      .controller('MyController', Controller);

  Controller.$inject = ['someService', 'otherService', '$state'];

  function Controller(someService, otherService, $state) {
    /**
     * @ngdoc property
     * @name vm
     * @propertyOf app.mymodule.controller:MyController
     * @description
     * A named variable for the `this` keyword representing the ViewModel
     */
        var vm = this,
      searchText;
    vm.customerService = customerService;
    vm.fetchCollection = fetchCollection;
    vm.deleteCustomer = deleteCustomer;

    initialise();

    function initialise() {
      //logic

    }
    /**
     * @ngdoc
     * @name fetchCollection
     * @methodOf app.mymodule.controller:MyController
     *
     * @description
     * Function to retrieve records from the backend service
     * @example
     * vm.fetchCollection(page, perPage);
     * @param {int} page The number of the page of data to be retrieved
     * @param {int} perPage The number of items per page to be retrieved
     * @returns {object} The response object returned from a httpPromise
     */
    function fetchCollection(page, perPage){
      //logic
    }

    function deleteCustomer(model) {
      //logic
  }
})();

如您所见,我有一些挂在 vm 变量上的属性,这些属性通常是对控制器中定义的函数的引用。

使用上面的 ngdocs\jsdocs 文档语法,我可以将 vm 属性输出到我的文档文件夹中,但我不确定如何记录 vm 对象本身的属性。

是否有明智或推荐的方法来做到这一点?我确实想知道不完全记录 vm 而只是分别记录每个 vm.xxx,但我对此不太确定!

谢谢

【问题讨论】:

    标签: angularjs jsdoc jsdoc3 grunt-ngdocs


    【解决方案1】:

    documentation里不是很清楚,但是你得用名字里的hash。

    试试这个。

    /**
     * @ngdoc property
     * @name app.mymodule.controller:MyController#vm
     * @propertyOf app.mymodule.controller:MyController
     * @description
     * A named variable for the `this` keyword representing the ViewModel
     */
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-02-25
      • 1970-01-01
      • 1970-01-01
      • 2016-07-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多