I have created a common search pipe for table, I have also added the column values to the select box, now I need to get the selected value from the select box and access it in my pipes
Below are the Code for your Reference
Pipe
export class searchPipe implements PipeTransform {
transform(values: any[], filter: string, selectedvalue:any): any {
console.log(selectedvalue);
if (!values || !values.length) return [];
if (!filter) return values;
filter = filter.toUpperCase();
if (filter && Array.isArray(values)) {
const keys = Object.keys(values[0]);
return values.filter(v => v && keys.some(k => v[k].toUpperCase().indexOf(filter) >= 0));
}
}
}
Html
<select *ngIf="showColFilter" [(ngModel)]="selecedValues">
<option *ngFor="let colValues of tabData | columnPipe">{{colValues}}</option>
</select>
<select [(ngModel)]="colvalues">
<div *ngFor="let colValues of tabData | columnPipe">
<option value="colValues">
</option>
</div>
</select>
Use this code to get value in ngModel
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.