Reputation: 69
I'm attempting to configure a navbar to collapse/expand on click of a data-target (hamburger icon).
When the view port is resized the navbar collapses, but it cannot be expanded to the contents of the navbar after collapse.
I have bootstrap installed as an npm package, but also referenced in the html to get it from maxcdn.
I have been using example 7 that can be found here.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="d-flex flex-grow-1">
<span class="w-100 d-lg-none d-block"><!-- hidden spacer to center brand on mobile --></span>
<a class="navbar-brand" href="#">
LOIFF
</a>
<div class="w-100 text-right">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggle">
<span class="navbar-toggler-icon"></span>
</button>
</div>
</div>
<div class="collapse navbar-collapse flex-grow-1 text-right" id="navbarToggle">
<ul class="navbar-nav ml-auto flex-nowrap">
<li class="nav-item" *ngIf="isUserAuthenticated()" [routerLinkActive]='["link-active"]' [routerLinkActiveOptions]='{ exact: true }'>
<a class="nav-link text-white" [routerLink]='["/"]'>My Team</a>
</li>
</ul>
</div>
</nav>
</body>
</html>
I have used Angular 6 *ngIf
expressions inside of some lists elements, I'm wondering does this cause the rendering to fail?
I've tried reordering the <script>
tags, as I seen some in some other posts that the order of the tags can matter.
I've also tried placing the script
tags inside of the body, instead of the header.
Upvotes: 1
Views: 143
Reputation: 7866
If you are using Angular, don't use Jquery/Bootstrap.js Angular has no control over that, Use Bootstrap css with ngBootstrap . See this Plunker for Navbar or Accordion etc.
Upvotes: 1