M
M
Mikenzzz2017-07-31 15:08:20
Angular
Mikenzzz, 2017-07-31 15:08:20

How to make such pipe filter in angular 4?

Good afternoon!
There is a filter.pipe.ts class that filters an array by given attributes.
For example:

<input #searchField (keyup)="0" type="text" class="form-control" id="search-left-input" placeholder="Строка поиска">
<li *ngFor="let field of fields | filter: 'name' : searchField.value" class="list-group-item">
       <label class="checkbox-inline">
       <input type="checkbox" name="fields" value="{{field.id}}" [checked]="field.checked" (change)="field.checked = !field.checked; onCheckboxFieldClick(field)">
         {{field.name}}
          </label>
</li>

But when it is necessary to filter two arrays, problems arise:
In this situation, it does not work:
<ul *ngFor="let well of wells | filter: 'field.name' : 'number' : searchObject.value" class="list-group" id="search-bottom-list">
      <li *ngFor="let testObject of well.testObjectOption | filter: 'name' : searchObject.value" class="list-group-item">
            <label class="checkbox-inline">
             <input type="checkbox" name="testObjects" value="{{testObject.id}}" [checked]="testObject.checked" (change)="testObject.checked = !testObject.checked">
               {{ well.field.name }} / {{ well.number }} / {{ testObject.name }} ({{ testObject.begin }} &mdash; {{ testObject.end }})
              </label>
          </li>
</ul>

How to make a filter for the situation above?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question