I am often confused between styles and ngstyles of angular 2.
When we should use styles and when we should user ngstyle in angular?
What is the purpose of both?
Any real time example for these?
Asked
Active
Viewed 478 times
1 Answers
2
It just depends if you have more than one style to add.
[style.background-color]="activity.status == 'Pending' ? 'red' : 'green'"
and
[ngStyle]="{'backgroundColor': activity.status == 'Pending' ? 'red' : 'green';''margin': functionExample()}"
And this is the same with [ngClass]
and [class.your-class]
This the question here: Set style dynamically in Angular2

Wandrille
- 6,267
- 3
- 20
- 43