mdlivingston / mat-select-filter

mat-select-filter
MIT License
28 stars 30 forks source link

How to use the options hasGroup and groupArrayName? #27

Open jeffersonveloso opened 2 years ago

jeffersonveloso commented 2 years ago

I tried to use mat-select-filter with the options hasGroup and groupArrayName and not work for me. What is the problem with my code? On file .ts

  test = [
    {
      name: 'Category 1.0',
      child: [
        {
          name: 'Category 1.1',
        },
      ],
    },
    {
      name: 'Category 2.0',
      child: [
        {
          name: 'Category 2.1',
        },
      ],
    },
  ];
  testFilterList = this.test.slice();

On file .html

<mat-form-field appearance="outline">
      <mat-select #select required>
        <mat-select-filter
          *ngIf="select.focused"
          [array]="test"
          [displayMember]="'name'"
          (filteredReturn)="testFilterList = $event"
          [hasGroup]="true"
          [groupArrayName]="'child'"
        ></mat-select-filter>
        <mat-option *ngFor="let item of testFilterList" [value]="item">
          {{ item.name }}
        </mat-option>
      </mat-select>
    </mat-form-field>