Changing button color on state changed angularjs

I have grey color button and i need to implement it with 2 states one for selected (blue)and other for idle state(grey). I am working on Angularjs. I am new to this platform.

Please provide tutorial or sample code with output.

Upvotes: 1

Views: 837

Answers (1)

tymeJV
tymeJV

Reputation: 104775

You would probably give a class that you can add to your button, say "selected". Next would be flipping a variable for when this btn is selected:

$scope.isSelected = true;

Now use `ng-class on the button:

<button ng-class="{'selected':isSelected}"></button>

Basically, when isSelected is true, add class selected.

EDIT: Working fiddle conveying this implementation

Upvotes: 3

Related Questions