DEV Community

Faisal Ahmed
Faisal Ahmed

Posted on

Filter system

      <div class="from">
        <mat-label>Banner Type</mat-label>
        <mat-form-field appearance="outline" >
          <mat-select formControlName="type" required>
            <mat-option [value]="'home_banner'">Home Page Banner</mat-option>
            <mat-option [value]="'all'">Home Page Banner</mat-option>
          </mat-select>
          <mat-error>This field is required.</mat-error>
        </mat-form-field>
      </div>
Enter fullscreen mode Exit fullscreen mode
private getAllBanner() {
  // Select
  const mSelect = {
    image: 1,
    name: 1,
    status: 1,
    priority: 1,
    info: 1,
    createdAt: 1,
    description: 1,
  };

  const filter: FilterData = {
    filter: this.filter,
    // filter: { type: 'all', status: 'publish' },
    pagination: null,
    select: mSelect,
    sort: { createdAt: -1 },
  };

  this.subDataOne = this.bannerService.getAllBanners(filter, null).subscribe({
    next: (res) => {
      if (res.success) {
        this.banners = res.data;
        this.bannerCount = res.count;
        this.holdPrevData = this.banners;
        this.totalBannersStore = this.bannerCount;
      }
    },
    error: (err) => {
      console.log(err);
    },
  });
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)