javascript - Angular, ternary in ng-click -


i have ternary inside ng-click swap value between 'bookmarks' , 'none'. first click change bookmarks works great second 1 not. think have wrong in syntax or logic. here code:

ng-click="current = 'bookmarks' ? current = 'bookmarks' : current = 'none' " 

i print {{current}} on screen , change bookmarks once i've toggled that. appreciate help. thanks!

your ternary expression wrong.

bookmarks(string) evaluated true so, current assigned bookmarks. seems work first time. however, next clicks assigned bookmarks.

use following expression:

ng-click = "current = (current == 'bookmarks') ? 'none' : 'bookmarks'" 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -