0

I am implementing some default styles for a div for a "condition id" as (id="default")

<div id="student" class="student"> /* if(id == "default") */

I need to set some other styles (class="changeStyle"), if the "condition id" is changed i.e. (id != "default")

<div id="student" class="changeStyle"> /*if(id != "default") */

which should be added dynamically, if it's finding the (id != "default").

Any suggesstion/example would be highly appreciated.

0

1 Answer 1

3

You can use ngClass

The ngClass directive allows you to dynamically set CSS classes on an HTML element by databinding an expression that represents all classes to be added.

Example: Here assuming ID is a variable in scope

<div 
  ng-class="{'changeStyle': id != 'default',  'student': id == 'default'}">
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.