Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- attendanceStatus:any;
- staffAttendanceList: StaffAttendance[] = [
- status:false,
- staff:{
- staffId:"ERP1001",
- firstName:'Rahul',
- lastName:'Sharma'
- }
- ];
- 2)In HTML:
- <input [(ngModel)]="searchStaffAttendance" type="text">
- <table>
- <tbody>
- <tr*ngFor="let staffAttendance of staffAttendanceList|filter:searchStaffAttendance:'staff.staffId';
- index as i">
- <td>{{i+1}}</td>
- <td>{{staffAttendance.staff.staffId}}
- </td>
- <td>{{staffAttendance.staff.firstName}}
- {{staffAttendance.staff.lastName}}</td>
- </tr>
- </tbody>
- </table>
- 3)In Filter pipe:
- import { PipeTransform, Pipe } from "@angular/core";
- @Pipe({
- name:'filter'
- })
- export class FilterPipe implements PipeTransform {
- transform = (value:[],filterString:any,propName:any):any => {
- let inputValue = [];
- if(filterString === undefined || filterString === '' ||
- value.length == 0){
- return value;
- }
- for(const item of value){
- if(item[propName] === filterString){
- inputValue.push(item);
- }
- }
- return inputValue;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment