0

I started working with angular and creating my "little" project. I came up to templating issue.

Basically, I try to set colour for elements dynamically with angular. I can't figure out what would be the best and the "right" way to do it.

Is it ok to use if statements in scope? Or better use directive?

My main goal is to be able to set colors from admin mode to toolbar and their icons.

Thank you for answers.

saulenzo7
  • 51
  • 12

2 Answers2

0

https://docs.angularjs.org/api/ng/directive/ngClass

You can use ngClass with any expression.

If what you are after is coloring odd/even rows of a table, you could also use

https://docs.angularjs.org/api/ng/directive/ngClassOdd https://docs.angularjs.org/api/ng/directive/ngClassEven

Bojan Bedrač
  • 846
  • 1
  • 7
  • 10
0

An example of ng-class

      <div ng-class="{'a-class': !if.someObjects.variable.negativeReponse,
                      'b-class': some.methodsResponse()
                      }" >
Lucas
  • 9,871
  • 5
  • 42
  • 52