I have a user object and I have a complex logic, that I want to unit test, which takes a user object and decides how it should be displayed - which css class should be used.
There are two approach that I consider:
<td class="{{ user | classify }}">
or
<td class="{{ user.cssClass }}"><!-- or --><td ng-class="user.cssClass">
or
<td ng-class="computeCssClass(user)">
The first approach assumes I create a filter that based on the provided user objects returns the css class.
The second approach assumes I add a new attribute cssClass
to the model and whenever a new user object is created (fetched from the REST API) I compute the cssClass
attribute.
The third approach assumes I create a function which computes the css class for the provided user object.
What are the pros and cons of the above two approaches?