Answer the question
In order to leave comments, you need to log in
How to iterate and render components in Angular 2?
Greetings! New to Angular. The task is next. There is an array of objects (components that take data from this array) that are rendered using the ngFor structural directive.
What if you want to render not all objects from the above array, but only some. In other words, is it possible to somehow filter the data in ngFor before rendering it. For example, if the property of one of the objects is false, then it is not rendered.
Interested precisely within the framework of structural directives or their interaction. If it is not possible, then tell me how to implement it in a different way.
Thank you!
Answer the question
In order to leave comments, you need to log in
inside ngFor put tags with ngIf condition
<tr *ngFor="let row of table['1'] | paginate: { itemsPerPage: 5, currentPage: currentPage}">
<td data-text="Номер карты" ngIf="row.ref_number">{{row.ref_number}}</td>
<td data-text="Личный товарооборот в баллах">{{row.my_bonus}}</td>
<td data-text="Товарооборот сети в баллах">{{row.ref_bonus}}</td>
<td data-text="Статус">
<label class="label" [ngClass]="{
'label-danger':row.status.id===0,
'label-success':row.status.id===1,
'label-info':row.status.id===2,
'label-warning':row.status.id===3}">{{row.status.name}}</label>
</td>
</tr>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question