【问题标题】:How do I set up a parent controller with Angular UI-Grid defaults and inherit from it?如何设置具有 Angular UI-Grid 默认值的父控制器并从中继承?
【发布时间】:2016-08-29 00:01:22
【问题描述】:

我在父控制器中有默认的 gridOptions。

EG:

  $scope.gridOptions = {
        rowHeight:50,
        headerHeight:50,
        onRegisterApi = function(gridApi,$scope){...}
}

实现 UI-Grids 的子控制器都继承了父 $scope,这似乎适用于原始类型的道具。

但是,在onRegisterApi 函数中,我需要能够访问不在父范围内的局部变量和方法。

我很确定我需要使用 JS 继承模式,但我很难让它发挥作用。我已经签出:http://blog.mgechev.com/2013/12/18/inheritance-services-controllers-in-angularjs/https://www.exratione.com/2013/10/two-approaches-to-angularjs-controller-inheritance/

【问题讨论】:

    标签: javascript angularjs inheritance angular-ui-grid


    【解决方案1】:

    这对我有用:What's the recommended way to extend AngularJS controllers?

    我将所有 UI-Grid 默认值放在一个基本控制器中,然后我在实现网格的控制器中扩展它。似乎工作正常,没有任何 $scope 问题。

    【讨论】:

      猜你喜欢
      • 2018-05-27
      • 2020-05-31
      • 2014-01-03
      • 1970-01-01
      • 2012-12-28
      • 1970-01-01
      • 2019-05-23
      • 1970-01-01
      • 2016-11-19
      相关资源
      最近更新 更多