0

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

1 Answer 1

2

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>`})
Sign up to request clarification or add additional context in comments.

4 Comments

Yes i tried but still facing same issue :( even also tried [ngStyle]="{'display': displayAttribute}"
sorry, it should be [attr.style.display]
same issue [object HTMLDivElement]
[style.display]="displayAttribute" is correct. Check the app.component.ts, the title has been hidden. @SarveshYadav

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.