How to toggle between two buttons and change color using angular

kate

I am trying to create two buttons, with both the buttons not selected on initial load. On clicking the first button, it gets selected and I am applying color for that. During initial load, the message displayed below the buttons is different from the one that is displayed after clicking the button . I have tried the logic to apply the color changes on toggle , but how do I deselect both the buttons on initial load and change the message appropriately.

Phong Lu

I think there are some issues with your code:

  • Really consider when using !boolVariable, try boolVariable = false.
  • Conditional operator ( bool ? return1 : return2 ) is used to return value, not to assign or apply logic.
  • I'm not so sure there is syntax like this ng-class="{true: 'green', false: 'blue'}[!yupNope.isSelected]" (maybe i'm not awared of new syntax).

Here the modified example, please try if it's what you want

plnkr.co/edit/yvMgUaPN8NPgSYYiXAhI?p=preview

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to toggle div visibility using radio buttons?

From Dev

How to change the color of my buttons on Mac OS?

From Dev

How to set rounded buttons with background color and change color on pressed

From Dev

Toggle between a RadioGroup of Toggle Buttons

From Dev

How to toggle Spannable foreground color using ClickableSpan

From Dev

How to toggle the visibility of two buttons using DataTrigger Behavior in XAML, WP 8.1?

From Dev

Toggle class between two buttons in Angular but restrict to prevent same button from changing class

From Dev

How to toggle between two Autohotkey configurations

From Dev

How to toggle two buttons on mouse hover?

From Dev

How to change indicator color in Toggle Button ( Android)

From Dev

How to Toggle Interior.Color using VBA

From Dev

How to change the color of a button for only a few seconds using angular?

From Dev

how to toggle between two css classes with react

From Dev

how to change background color of my two td's using jQuery?

From Dev

How to change the color of two elements using javascript?

From Dev

How to set rounded buttons with background color and change color on pressed

From Dev

Android: how to change color to buttons of AlertDialogFragment

From Dev

Using buttons to change color in WebGL

From Dev

How can I change the background color of table cell (td) using two buttons for different colors?

From Dev

jQuery change/toggle classes between buttons from inside PHP loop

From Dev

How to toggle between two Autohotkey configurations

From Dev

Button change color on toggle using jQuery

From Dev

iOS: change background color using multiple buttons

From Dev

How can I change color of background using a group of radio buttons?

From Dev

How to change the color of text between two positions?

From Dev

how to toggle between two images

From Dev

How to change color of pair of buttons tapped?

From Dev

Mutual Toggle buttons - Using two toggle buttons to represent tri-state using triggers

From Dev

How to toggle between two images with a button using Javascript code?

Related Related

  1. 1

    How to toggle div visibility using radio buttons?

  2. 2

    How to change the color of my buttons on Mac OS?

  3. 3

    How to set rounded buttons with background color and change color on pressed

  4. 4

    Toggle between a RadioGroup of Toggle Buttons

  5. 5

    How to toggle Spannable foreground color using ClickableSpan

  6. 6

    How to toggle the visibility of two buttons using DataTrigger Behavior in XAML, WP 8.1?

  7. 7

    Toggle class between two buttons in Angular but restrict to prevent same button from changing class

  8. 8

    How to toggle between two Autohotkey configurations

  9. 9

    How to toggle two buttons on mouse hover?

  10. 10

    How to change indicator color in Toggle Button ( Android)

  11. 11

    How to Toggle Interior.Color using VBA

  12. 12

    How to change the color of a button for only a few seconds using angular?

  13. 13

    how to toggle between two css classes with react

  14. 14

    how to change background color of my two td's using jQuery?

  15. 15

    How to change the color of two elements using javascript?

  16. 16

    How to set rounded buttons with background color and change color on pressed

  17. 17

    Android: how to change color to buttons of AlertDialogFragment

  18. 18

    Using buttons to change color in WebGL

  19. 19

    How can I change the background color of table cell (td) using two buttons for different colors?

  20. 20

    jQuery change/toggle classes between buttons from inside PHP loop

  21. 21

    How to toggle between two Autohotkey configurations

  22. 22

    Button change color on toggle using jQuery

  23. 23

    iOS: change background color using multiple buttons

  24. 24

    How can I change color of background using a group of radio buttons?

  25. 25

    How to change the color of text between two positions?

  26. 26

    how to toggle between two images

  27. 27

    How to change color of pair of buttons tapped?

  28. 28

    Mutual Toggle buttons - Using two toggle buttons to represent tri-state using triggers

  29. 29

    How to toggle between two images with a button using Javascript code?

HotTag

Archive