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
Post a Comment