1

On button click function CSS style to be called with in the TS file

html code:

    <div class="overlay-loader">
    <div *ngIf="isLoading" class="loader"></div>
    <p *ngIf="results">{{ results | json }}</p>
    <p *ngIf="error">Error: {{ error | json }}</p>
    </div>
    <p>
    <button (click)="getResult()">Get result</button>
    </p>

Link which i have tried:https://stackblitz.com/edit/angular-loader-kspfhg?ctl=1&embed=1&file=app/app.component.html&view=editor After clicking the button overlay-loader css class to be loaded and once data get fetched css overlay-loader to be dissaper

1 Answer 1

1

Use ngClass to add a class conditionally:

<div [ngClass]="{'overlay-loader': isLoading}">
Sign up to request clarification or add additional context in comments.

Comments

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.