Reputation: 1632
I am trying to hide a table data using the following:
<td *ngFor="let tableHeaderItem of gridHeaderData"
[ngStyle]="{'hidden' : tableHeaderItem.hidden ? 'none' : 'table-cell'}">
but it isn't working. I tried removing the quotes 'hidden'
to hidden
but it just doesn't work.
Upvotes: 2
Views: 2131
Reputation: 657536
Instead of ngStyle
you can also use the hidden
property:
<td *ngFor="let tableHeaderItem of gridHeaderData"
[hidden]="tableHeaderItem.hidden">
Upvotes: 0
Reputation: 1632
what a mistake!... ur rite, alternately i made it working by doing to following
[style.display]="tableHeaderItem.hidden ? 'none' : 'table-cell'"
Upvotes: 3
Reputation: 24535
You need to have a CSS
class named hidden
that has display: none
for this to work. Otherwise you could try the following:
<td *ngFor="let tableHeaderItem of gridHeaderData"
[ngStyle]="{'display' : tableHeaderItem.hidden ? 'none' : 'table-cell'}">
See the official Angular2 documentation on the ngStyle
directive for more details.
You could also use [style.display]
like this:
<td *ngFor="let tableHeaderItem of gridHeaderData"
[style.display]="tableHeaderItem.hidden ? 'none' : 'table-cell'">
Upvotes: 5