I have this
body
div(ng-class="toggle ? 'nav-open' : 'nav'")
.container
.logo
img(src='images/logo.png')
span Motto
ul(ng-class="toggle ? 'menu-open' : 'menu'")
li
a(href="#!/", ng-click='toggle = !toggle') Home
li
a(href="#!/products", ng-click='toggle = !toggle') Products
activated first by this
button.upon(type="button", ng-click='toggle = !toggle') Menu
and you see it closes clickin on a link. The problem is that when I close it by a click it doesnt' work anymore, must refresh the page in order to do it, and using this while on mobile it just closes without changing the page. What am I doing wrong and/or is there any better way to achieve what I'm doin?
Check out some of the examples in the docs - there's a few different ways to use ngClass. https://docs.angularjs.org/api/ng/directive/ngClass
I think this syntax should probably work for your case:
ng-class="{'nav-open': toggle, 'nav': !toggle}"
ng-class="{'menu-open': toggle, 'menu': !toggle}"
Essentially you're providing ngClass with a configuration object that says: "Apply the nav-open
class when toggle
is true
, and apply the nav
class when toggle
is false".
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments