angular - Angular2 hide element in ng-for -
how filter elements when using ng-for?
<tr> <td *ng-for="#col of columns" ><a (click)="sort(col.name)">{{col.title}}</a></td> </tr> i don't want create element when col.visible false
how do in angular2?
use ngif directive. col.visible = true means td added otherwise won't added in tr.
the ngif directive removes or recreates portion of dom tree based on {expression}. if expression assigned ngif evaluates false value element removed dom, otherwise clone of element reinserted dom.
<tr> <td ng-if="col.visible" ng-for="#col of columns" ><a ng-click="sort(col.name)">{{col.title}}</a></td> </tr>
Comments
Post a Comment