如何在typescript Angular2中动态地将值绑定到属性?
我试图获取条件值,该值来自typescript中导出的类,但无法获取dispay属性值,并且在浏览器上显示[object HtmlLevel]如何在typescript Angular2中动态地将值绑定到属性?,typescript,angular,Typescript,Angular,我试图获取条件值,该值来自typescript中导出的类,但无法获取dispay属性值,并且在浏览器上显示[object HtmlLevel] @Component({ template:`<div #noRecordFoundMsg class="ui-widget-header ui-helper-clearfix" style="padding:4px 10px;border-bottom: 0 none;display:{{ displayAttr
@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";
}
}
@组件({
模板:`您是否尝试过,[style.display]=“displayAttribute”
:
@组件({
模板:`您是否尝试过,[style.display]=“displayAttribute”
:
@组件({
模板:`是的,我尝试过,但仍然面临相同的问题:(甚至还尝试过[ngStyle]=“{'display':displayAttribute}”对不起,它应该是[attr.style.display]
相同的问题[object htmldevelment][style.display]=“displayAttribute”是正确的。请检查,标题已被隐藏。@SarveshYadavYes我尝试过,但仍然面临相同的问题:(甚至还尝试了[ngStyle]=“{'display':displayAttribute}”对不起,它应该是[attr.style.display]
同一问题[object HtmlDevice][style.display]=“displayAttribute”是正确的。请检查,标题已隐藏。@SarveshYadav
@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>`})