Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to pass angular css class to html page

In my component.css file I have a class.

.blur-map-report {
  filter: blur(8px);
  -webkit-filter: blur(4px);
}

In my component.ts file has property something like this

hasError = false

In my component.html file has another class also called map-report.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<div id="map" class="map-report"></div>

Here I want to add only blur-map-report class if the hasError becomes true. if not only need to keep map-error class. if hasError true I want to keep both the class.

So how can I apply this class conditionally

>Solution :

You can use class binding to conditionally add the class to your div:

<div id="map" class="map-report" [class.blur-map-report]="hasError"></div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading