Module “primeng/utils”没有导出成员”FilterUtils”。

huangapple go评论73阅读模式
英文:

Module '"primeng/utils"' has no exported member 'FilterUtils'

问题

升级 Angular 到 v15 后,我遇到了这个错误:

> 模块 "'primeng/utils'" 没有导出成员 "'FilterUtils'"。

是否有不需要更改代码的替代方法来进行筛选?

import { FilterUtils } from ''primeng/utils'';

filterStatus(event: Switch, dt: Table): void { 
  this.showErrorOnly = event.checked;
  if (event.checked) {
    dt.value = FilterUtils.filter(this.data, ['validation.status'], 'INVALID', 'contains');
  } else {
    dt.value = this.data;
  }
  dt.reset()
}
英文:

After upgrading Angular to v15 I am getting this error:

> Module '"primeng/utils"' has no exported member 'FilterUtils'.

Is there any alternative of filtering like this without code changes?

import { FilterUtils } from 'primeng/utils';

filterStatus(event: Switch, dt: Table): void { 
  this.showErrorOnly = event.checked;
  if (event.checked) {
    dt.value = FilterUtils.filter(this.data, ['validation.status'], 'INVALID', 'contains');
  } else {
    dt.value = this.data;
  }
  dt.reset()
}

答案1

得分: 1

FilterUtils 在 PrimeNG 11 中被移除,FilterService 类被提供作为替代品:

import { FilterService } from 'primeng/api';

@Component({
  ...
  providers: [FilterService] // 你也可以在 AppModule 中全局提供它
})
class SomeComponent {
  constructor (private readonly filterService: FilterService) {}

  filterStatus(event: Switch, dt: Table): void { 
    this.showErrorOnly = event.checked;
    if (event.checked) {
      dt.value = this.filterService.filter(this.data, ['validation.status'], 'INVALID', 'contains');
    } else {
      dt.value = this.data;
    }
    dt.reset();
  }
}
英文:

FilterUtils were removed in PrimeNG 11 and the FilterService class was provided as the replacement:

import { FilterService } from 'primeng/api';

@Component({
  ...
  providers: [FilterService] // you can also provide it globally in the AppModule
})
class SomeComponent {
  constructor (private readonly filterService: FilterService) {}

  filterStatus(event: Switch, dt: Table): void { 
    this.showErrorOnly = event.checked;
    if (event.checked) {
      dt.value = this.filterService.filter(this.data, ['validation.status'], 'INVALID', 'contains');
    } else {
      dt.value = this.data;
    }
    dt.reset();
  }
}

答案2

得分: 0

使用import { FilterUtils } from 'Primeng/utils';PrimeNg版本11中已被弃用。如果您想要不进行代码更改的解决方案,我建议您将PrimeNg版本降级到v10.0.0(lts)。请查看官方PrimeNg v10文档此处

英文:

Use of import { FilterUtils } from 'Primeng/utils'; is deprecated in PrimeNg version 11. If you are looking for something without a code change. I suggest you to downgrade the version of primeNg to v10.0.0(lts) Please find the official PrimeNg v10 documentation here.

huangapple
  • 本文由 发表于 2023年6月12日 18:10:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/76455603.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定