代码之家  ›  专栏  ›  技术社区  ›  Roberto Vieira

我的离子搜索栏过滤器不工作

  •  0
  • Roberto Vieira  · 技术社区  · 2 年前

    我的应用程序的初始部分包括从数据库加载数据,并使用垫子手风琴显示,如下所示:

    async getVouchers() {
    this._HttpService.get(${ServerUrl.ApiUrl}voucher).then(data => {
    this.result = data;
    
      if (this.result.vouchers.length > 0) {
        this.hasVoucher = true;
        this.dataSource = this.result.vouchers;
      }
      else {
        this.hasVoucher = false;
      }
    
      this.skeleton = true;
    })
    }
    
      <div class="ion-margin-top ion-margin-bottom" *ngFor="let data of dataSource">
          <mat-accordion>
            <mat-expansion-panel>
              <mat-expansion-panel-header>
                <mat-panel-title>
                  {{ data.name }}
                </mat-panel-title>
              </mat-expansion-panel-header>
    
              <p>{{'voucher.messageTable' | transloco}} {{data.message}}</p>
              
              ....
              </mat-expansion-panel>
          </mat-accordion>
        </div>
    

    我正在努力创建一个过滤器,但没有工作。

    <ion-searchbar show-clear-button=“always” placeholder=“Search” (keyup)=“filterVoucher($event)”>
    
    filterVoucher(event: Event) {
    const filterValue = (event.target as HTMLInputElement).value;
    this.dataSource.filter = filterValue.trim().toLowerCase();
    }
    

    有人可以帮我完成这个过滤器吗??

    定义了一个离子搜索栏,并用Angular/javascript创建了基本过滤器,但它不起作用。

    0 回复  |  直到 2 年前