gpt4 book ai didi

angularjs - 将 angularCompileRows 设置为 true 时,无法读取 null 的属性 '$apply'

转载 作者:行者123 更新时间:2023-12-03 08:24:30 25 4
gpt4 key购买 nike

我使用 AngularJS 1.7 和 ag-grid 18.0.1。

当我将 angularCompileRows 设置为 true 时,控制台中出现此错误:

Uncaught TypeError: Cannot read property '$apply' of null
at eval (rowRenderer.js:586)

这是对应的代码(这是agGrid代码):
RowRenderer.prototype.checkAngularCompile = function () {
var _this = this;
// if we are doing angular compiling, then do digest the scope here
if (this.gridOptionsWrapper.isAngularCompileRows()) {
// we do it in a timeout, in case we are already in an apply
setTimeout(function () {
_this.$scope.$apply();
}, 0);
}
};

这是我的选择:
const gridOptions = {
rowData: null,
columnDefs: [...],
enableColResize: true,
onColumnResized: (params) => {
angularCompileRows: true,
suppressCellSelection: true,
enableSorting: true,
enableServerSideSorting: true,
rowModelType: 'infinite',
pagination: true,
paginationPageSize: 10,
unSortIcon: true,
suppressPaginationPanel: true,
suppressHorizontalScroll: true,
onGridReady: (params) => {
const dataSource = {
rowCount: null, // behave as infinite scroll
getRows: (rowsParams) => {
// call my API then rowsParams.successCallback(data, isLastPage);
},
};

gridOptions.api.setDatasource(dataSource);
},
};

调用栈

enter image description here

以及调试选项的输出

enter image description here

网格正在呈现:标题没问题,但内容为空。

普朗克 https://plnkr.co/edit/j5ubZWit4CO5zmldgqnl?p=preview基于这个例子 https://www.ag-grid.com/javascript-grid-infinite-scrolling/#example-2-equal-pagination-page-size-and-large-infinite-block-si并添加 angularCompileRows: true选项

编辑:这是一个带有 Angular 应用程序的 plunker https://plnkr.co/edit/7eOKSXbcCzLdYWtPygrS?p=preview

错误没有被触发,但 angularCompileRows 似乎没有被调用

最佳答案

如果您打算在网格中使用 angular,为什么不先加载 angular :)。您没有加载 angular,也没有在网格中使用任何 angular 代码,如何调用 $scope.$apply()没有那个?

制作 angularCompileRows = false和你的网格工作。如果您要使用 angular,请从 angular 示例开始。

关于angularjs - 将 angularCompileRows 设置为 true 时,无法读取 null 的属性 '$apply',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51039643/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com