使用数字范围 [Angular 7] 过滤 Material Table

Filtering a Material Table with numbers ranges [Angular 7]

我在我的 Angular 7 项目中使用 Material Table。

我有一个显示多个对象的table。

每个对象都有一个 属性 'number of promotions',我想使用数字范围(小于 5,从 6 到 10,从 11 到 20,大于20).

这是 dataSource.filterPredicate 的一个示例,我曾经在我的 table 上使用自定义过滤器,但我不知道如何管理我之前解释过的过滤器...

        this.dataSource.filterPredicate = (data: Store, filter: string) => {
      switch (this.filterCriteria) {
        case 'approval':
          if (filter === 'null' || filter === '') {
            return (data);
          } else {
            return (data.approval.trim().toLowerCase().indexOf(filter) !== -1
            );
          }

我确实设法解决了我的问题,而且我非常非常非常简单。 -_-'

我的 dataSource.filterPredicate.

上有一个带有正确过滤器的开关盒
      case 'promotion':
          if (filter === 'null' || filter === '') {
            return (data);
          } else {
            switch(filter){
              case '5':
              return (data.total_promotions <= 5);
              case '10':
              return (data.total_promotions > 5 && data.total_promotions <= 10);
            }
          }
      }