2016-06-25 16 views
0

Ich versuche Bedingungswert zu erhalten, die in Typoskript Form exportiert Klasse kommt aber nicht in der Lage für dispay Attributwert zu erhalten und auf Browser mich zeigt [object HTMLDivElement]Wie binden Sie den Wert dynamisch an das Attribut Angular2?

@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"; 
        } 
    } 

Antwort

2

Haben Sie versucht, [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>`}) 
+0

Ja ich habe versucht, aber immer noch gleiches Problem konfrontiert :(sogar versucht, auch [ngstyle] = "{ 'display': displayAttribute}" –

+0

sorry, sollte es '[attr.style.display]' – AngJobs

+0

gleiches Problem sein [object HTMLDivElement] –

Verwandte Themen