I am struggling. Hope you could help
I have given the following code segment in an Angular Project. In this, teacher-table component's component.ts file, need the logic for searching inside the function
Input : Searching text
Output: Update the teacherdata array of the teacher class.
I have given the following code segment in an Angular Project. In this, teacher-table component's component.ts file, need the logic for searching inside the function
Input : Searching text
Output: Update the teacherdata array of the teacher class.
Code:
search(value) {
let foundItems = [];
if (value.length <= 0) {
this.getTeacherData();
} else {
let b = this.teacherData.filter((teacher) => {
if (teacher[0].name.toLowerCase().indexOf(value) > -1) {
foundItems.push(teacher)
}
});
this.teacherData = foundItems;
}
}