Raru Chempazhanthy
Raru Chempazhanthy

Reputation: 67

Add a class by checking a condition in angular 6

I need to add a class 'test1' if the values in 'emp_code' and 'emp' is same.

I had tried with the code,

class="{{ emp_empcode == emp ? 'test1' : 'test2' }}"

I had tried with this and this

Any other way? Thanks a lot in advance.

Upvotes: 0

Views: 42

Answers (1)

yannick
yannick

Reputation: 715

[class.test1]="emp_code == emp"

should definitively work. You can also take a look at https://toddmotto.com/ng-class-angular-classes for more varieties

Upvotes: 2

Related Questions