0
I have the array:
lista = [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }];
And I want to filter the objects from what the user type into two inputs:
<input nz-input [(ngModel)]="filtro.user" (keyup)="filtrar()" />
<input nz-input [(ngModel)]="filtro.age" (keyup)="filtrar()" />
For that in function filtrar
I do the following using the lodash
:
filtrar(): void {
this.lista = _.filter(this.lista, this.filtro);
}
But, if the user only type "bar"
in the first input and only the first age digit in the second input "3"
the array returned by _.filter
will be empty, returning some object only if I type the full name of 'barney'
or 'fred'
or the full age.
Is there any way to return the object { 'user': 'barney', 'age': 36 }
entering only a part of the value of 'user
' and 'age'
? For example if in the first input type 'bar'
and in the second digit '3'
I wanted to return { 'user': 'barney', 'age': 36 }