-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Navbar not collapsing without ui-bootstrap #458
Comments
Ah btw, even after going back to my very first commit without any changes to the generated code, the navbar is not working. |
Did you include ui-bootstrap? If not, there is a good chance that the bootstrap vendor script has already fired off before the navbar was loaded. If you're not using bootstrap-ui, you'll need to manually initialize the collapse behavior. Check out the docs for more info on collapse and how to initialize it. Let me know if that does the trick. |
Okay, I tried it out with two clean installs, one with ui-bootstrap and one without. With ui-bootstrap included in the build, it works fine. I'll try to manually run the collapse script, but I would be good to fix the generator too or at least notify new users somewhere, wouldn't it? |
I'm not sure what the right course of action is, but I do know this is typical behavior with asynchronous page loading, ie: DOM gets added after |
Actually, the proper thing to do would be write a directive for the behavior. angular.module('YOUR_APP_NAME')
.directive('navbarCollapse', function () {
return function postLink(scope, element) {
var nav = element.find('.navbar-collapse').collapse();
element.find('button.navbar-toggle').click(function() { nav.collapse('toggle'); });
};
}); Then just place the |
Great answer @kingcody. |
Thanks for the answer! |
+1 |
Depending on your version of UI-Bootstrap you might have to modify
|
Hey,
I just tried out the generator and noticed after some changes to the generated project, that the navbar is not collapsing. It seems the directive "collapse" is missing or at least I cannot find it. Am I missing something here?
The text was updated successfully, but these errors were encountered: