0

I'm using primeng p-drowpdown component to filter a table it's options are coming dynamically i want to set a default filtered option so that when the component is initialized the table date will be filtered by this default value automatically, i used [filterValue] property and set it the the first option of the dropdown but it still doesn't work

                  <th class="text-center filters">
                    <p-columnFilter
                      matchMode="contains"
                      field="Date"
                      [showMenu]="false"
                    >
                      <ng-template
                        pTemplate="filter"
                        let-value
                        let-filter="filterCallback"
                      >
                        <p-dropdown
                          [filterValue]="dateArray[0]"
                          [ngModel]="value"
                          [options]="dateArray"
                          (onChange)="filter($event.value)"
                          placeholder="Date"
                          [showClear]="true"
                          [filter]="true"
                        >
                        </p-dropdown>
                      </ng-template>
                    </p-columnFilter>
                  </th>
sameh
  • 31
  • 4

1 Answers1

0

Try using [(ngModel)]="this.defaultValue" and in TS file just pass the whatever dropdown's default value you want in defaultValue variable. Of course you need to initialize it in the TS file first then use only you can use it in the TS and HTML files.

I Hope this helps you!!

Purvang
  • 23
  • 3