1

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.

1
  • In javascript we can take reference to the button and change the background. How do we do it in ANGULARJS Commented Apr 28, 2014 at 13:50

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

3 Comments

Was in the process of creating an answer w/ fiddle, here is fiddle which would match this answer... jsfiddle.net/KgShW/1
@Brocco your answer made things simpler if you would have posted as answer instead of comment i would have selected it as answer. Anyways Thanks a ton for fiddle :)
@NiranjanBalkrishnaPrajapati I appreciate that, but in reality they are the same answer just in different forms. And because his answer was submitted after I created the fiddle it was appropriate to place it here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.