Saturday, December 8, 2018

Difference Between ngStyle and ngClass

ngStyle is used to interpolate javascript object into style attribute, not css class.

Following directive will be translated to style="color:red"

ngStyle="{color: 'red'}"
And ng-class directive translates your object into class attribute.

Following will be translated to class="deleted" when isDeleted variable is true.

ngClass="{'deleted': isDeleted}"

No comments:

Followers

Link