BigBadVlada
BigBadVlada

Reputation: 9

How can I set ng-style attribute to be equal to object value?

What I need is to set color of output text to a selected color, I figured out that I should use ng-style but i dont know how.

Plunker code:

<html>http://plnkr.co/edit/XFCMcjwYtxIInc8lMQaC?p=preview</html>

For example, when you create group you get groupname - selectedcolorfromform, I need groupname to be coloured in selected color

Upvotes: 0

Views: 145

Answers (1)

Rasalom
Rasalom

Reputation: 3111

Just add ng-style="{color : model.color}"

See an example here: https://docs.angularjs.org/api/ng/directive/ngStyle

http://plnkr.co/edit/rOUwOUR1s3OPHsnG2Qh0?p=preview

Upvotes: 1

Related Questions