【问题标题】:How do I render angular directive inside an ag-grid cellEditor Component?如何在 ag-grid cellEditor 组件中呈现角度指令?
【发布时间】:2016-08-17 00:52:44
【问题描述】:

我正在尝试在自定义 ag-grid 单元格编辑器中呈现角度自动完成指令。在渲染时,指令不会被编译,而是在单元格编辑器中打印原始 html。反正有没有让它呈现为角度指令?

【问题讨论】:

    标签: javascript angularjs ag-grid


    【解决方案1】:

    我想出了使用 angular 的 $compile 将 angular 指令渲染成 html 的解决方案。

    代码:

    CategoryEditor.prototype.init = function (params) {
      this.container = document.createElement('div');
      this.container.tabIndex = "0";
    
      this.dropdown = document.createElement('div');
      this.dropdown.setAttribute("dynamic", "html");
      this.container.appendChild(this.dropdown);
      //My directive is of the form <div dynamic="html"></div>
    
      var that = this;
      $scope.selectedCallback = function ($item) {
        that.selectCategory($item);
        params.stopEditing();
      };
      $compile(this.container)($scope);
      $scope.$digest();
    };
    

    【讨论】:

      【解决方案2】:

      确保您有 angularCompileRows=true 以使 angular 1 在 ag-Grid 中工作

      【讨论】:

      • 只是没有用。我必须使用 $compile 才能让它工作。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-04-21
      • 1970-01-01
      • 1970-01-01
      • 2017-04-08
      • 2016-06-23
      • 2019-10-26
      • 2020-10-30
      相关资源
      最近更新 更多