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

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -