首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在angularJS中使用带有控制器属性的ngdocs

在angularJS中使用带有控制器属性的ngdocs
EN

Stack Overflow用户
提问于 2015-12-30 22:44:02
回答 1查看 1.2K关注 0票数 2

我刚刚开始在我的angular应用程序中使用grunt-ngdocs来掌握grip,到目前为止还不错。

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

考虑以下代码:

代码语言:javascript
复制
(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属性输出到documentation文件夹中,但我不确定如何记录vm对象本身的属性。

有没有一种明智的或推荐的方法来做到这一点?我确实想知道为什么不完全记录vm,而只是单独记录每个vm.xxx,但我不太确定这一点!

谢谢

EN

回答 1

Stack Overflow用户

发布于 2016-05-15 20:45:46

这在documentation中不是很清楚,但您必须在名称中使用散列。

尝尝这个。

代码语言:javascript
复制
/**
 * @ngdoc property
 * @name app.mymodule.controller:MyController#vm
 * @propertyOf app.mymodule.controller:MyController
 * @description
 * A named variable for the `this` keyword representing the ViewModel
 */
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34531647

复制
相关文章

相似问题

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