6

I have this code:

<select ng-options="key as value for (key, value) in {{set.values}}" ng-init="set.value" ng-model="item.styles[group][name].value"></select>

I need to set a style to the options like this (generated):

<option style="background: green;">
<option style="background: red;">

How? Is it possible? Or do I need a directive or some other fancy code?

Artemis
  • 2,553
  • 7
  • 21
  • 36
Jens Törnell
  • 171
  • 3
  • 9

1 Answers1

-1

You can apply conditional styles via Angular's built-in ng-style directive

Markup

<span ng-style="myStyle">Sample Text</span>

Logic

$scope.myStyle = {
   background: '#000000'
};

Where the directive takes any valid expression

See also:

How do I conditionally apply CSS styles in AngularJS?

Community
  • 1
  • 1
Wottensprels
  • 3,307
  • 2
  • 29
  • 38