I am trying to get condition value which is coming form exported class in typescript but unable to get for dispay attribute value and on browser it showing me [object HTMLDivElement]
@Component({
template:`<div #noRecordFoundMsg class="ui-widget-header ui-helper-clearfix"
style="padding:4px 10px;border-bottom: 0 none;display:{{ displayAttribute }}"> <-----here
<span>{{ noRecordFoundMsg }}</span>
</div>`})
private displayAttribute: string;
exported class Demo{
//some code
if (Counts === 0) {
this.noRecordFoundMsg = "No Record Found";
this.displayAttribute = "none";
} else {
this.displayAttribute = "block";
}
}
asked Jun 25, 2016 at 11:31
Sarvesh Yadav
2,6307 gold badges26 silver badges41 bronze badges
1 Answer 1
Have you tried, [style.display]="displayAttribute":
@Component({
template:`<div #noRecordFoundMsg class="ui-widget-header ui-helper-clearfix"
[style.display]="displayAttribute"
style="padding:4px 10px;border-bottom: 0 none;"> <-----here
<span>{{ noRecordFoundMsg }}</span>
</div>`})
answered Jun 25, 2016 at 12:08
null canvas
10.7k2 gold badges17 silver badges18 bronze badges
Sign up to request clarification or add additional context in comments.
4 Comments
Sarvesh Yadav
Yes i tried but still facing same issue :( even also tried [ngStyle]="{'display': displayAttribute}"
null canvas
sorry, it should be
[attr.style.display]Sarvesh Yadav
same issue [object HTMLDivElement]
Zen
[style.display]="displayAttribute" is correct. Check the app.component.ts, the title has been hidden. @SarveshYadav
lang-js