import { Component, OnInit } from '@angular/core'; @Component({ selector: 'app-comp1', templateUrl: './comp1.component.html', styleUrls: ['./comp1.component.scss'] }) export class Comp1Component implements OnInit { employees: any; employeeList: any; nameFilter: string = ''; cityFilter: string = ''; constructor() { } ngOnInit(): void { this.employeeList = [ { "id": 1, "name": "Csendes Irén", "city": "Szeged" }, { "id": 2, "name": "Csendes Borbála", "city": "Pécs" }, { "id": 3, "name": "Felhős Béla", "city": "Szeged" }, { "id": 4, "name": "Lind Evelin", "city": "Pécs" }, { "id": 5, "name": "Csendes Lajos", "city": "Szegi" }, { "id": 6, "name": "Csendes Ágnes", "city": "Szegi" }, { "id": 7, "name": "Arany Tamás", "city": "Szegi" }, { "id": 8, "name": "Rendes Valér", "city": "Szerencs" }, { "id": 9, "name": "Éles Gábor", "city": "Szerencs" }, { "id": 10, "name": "Remek Imre", "city": "Szegi" }, { "id": 11, "name": "Vilka Lajos", "city": "Szegi" }, ] this.employees = this.employeeList; } changeNameFilter(content: string) { this.nameFilter = content; this.changeFilter(); } changeCityFilter(content: string) { this.cityFilter = content; this.changeFilter(); console.log('vmi') } changeFilter() { let a = this.employeeList.filter( (emp:any) => { if( emp.name.indexOf(this.nameFilter)>-1 && emp.city.indexOf(this.cityFilter)>-1) { return emp; } }) this.employees = a; } }