Dismiss
Announcing Stack Overflow Documentation

We started with Q&A. Technical documentation is next, and we need your help.

Whether you're a beginner or an experienced developer, you can contribute.

Sign up and start helping → Learn more about Documentation →

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";
                    }
    }
share|improve this question
up vote 2 down vote accepted

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>`})
share|improve this answer
    
Yes i tried but still facing same issue :( even also tried [ngStyle]="{'display': displayAttribute}" – Sarvesh Yadav Jun 25 at 12:12
    
sorry, it should be [attr.style.display] – AngJobs Jun 25 at 12:33
    
same issue [object HTMLDivElement] – Sarvesh Yadav Jun 25 at 12:47
1  
[style.display]="displayAttribute" is correct. Check the app.component.ts, the title has been hidden. @SarveshYadav – Zen Jun 26 at 3:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.