On my webpage, I have a list of data presented in divs
. Each div corresponds to an array of data in my object, which is a common setup.
I am currently working on implementing a text box that will allow me to filter the displayed data as more information is entered into the box. This way, users can quickly narrow down the results shown on the page.
To enable this filtering functionality, I have added a filter to my ngFor
directive:
*ngFor="let x of data | filter: filterString"
.
The text-box utilizes ngModel
to handle the filtering:
<input type="text" class="form-control" placeholder="Filter..." name="ruleFilter" id="ruleFilter" [(ngModel)]="filterString" (keyup)="onFilter($event)">
However, I am running into an issue where the filter only seems to be effective on the top layer of data within my object. For instance, searching for Omaha
works fine because it's at the top level and gets filtered correctly.
But when attempting to search for something like Campus
, which is nested inside Attribute
, the filter doesn't recognize it, resulting in no matching results being displayed.
Is there a way to configure the model to search through all layers of the object for binding instead of just looking at the top layer (which I suspect is happening currently)?
Update: I have created a plunker showcasing the basic setup of my application: https://plnkr.co/edit/eywuWmPRseUkmVPbTEOf?p=preview
In the provided example, you'll notice that the data model searches by top-level properties effectively but fails to return any results when searching for nested items.