I
I
Ivan Stroykin2016-12-09 17:55:47
Angular
Ivan Stroykin, 2016-12-09 17:55:47

How can ngFor and ngif be used together?

Good day,
is it possible to somehow use *ngFor and *ngIf together?
Construction example:

<tr *ngFor="let row of review.penalty" *ngIf="row.sum > 10">
    <td>{{row.name}}</td>
    <td>{{row.sum | number:'.2'}}</td>
</tr>

This design doesn't work. It worked in angularjs. Should they have been replaced somehow?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Zuev, 2016-12-09
@StivinKing

Can be
1) wrapped in ng-container

<ng-container *ngFor="let row of review.penalty">
  <tr *ngIf="row.sum > 10">
    <td>{{row.name}}</td>
    <td>{{row.sum | number:'.2'}}</td>  
  </tr>
</ng-container>

Example
2) use template
<template ngFor let-row [ngForOf]="review.penalty">
  <tr *ngIf="row.sum > 10">
    <td>{{row.name}}</td>
    <td>{{row.sum | number:'.2'}}</td>  
  </tr>
</template>

Example

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question