How to change navigation bar name and icons dynamically on each page based on url ? Angular 2 - angular2-routing

I need to change the navigation bar names and icons dynamically based on the page URL.
Here is my code:
<nav id="brand" class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<div class="navbar-brand">
<img src="{{wifiStatusIcon}}" class="wifiStatusIcon">
</div>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li> <h3 class="pageName" ng-bind="$root.name">{{title}} </h3> </li>
<li><a class="headerIconATag"><img class="headerIcon" src="{{headerIcon}}"></a></li>
</ul>
</div>
<!--/.nav-collapse -->
</div>

Attach click event on all links and call component function ,in that function change all your binded variable like status icon,wifiicon
<ul class="nav navbar-nav">
<li>{{title}} </h3> </li>
<li><a class="headerIconATag"><img class="headerIcon" src="{{headerIcon}}"></a></li>
</ul>
In Component create a function named routeChange
routeChange(route:string){
if(route==="\material"){
this.wifiStatusIcon ="icon/"
}else{
this.wifiStatusIcon ="icon2"
}
}

Related

How can I put the navigation above the main layout container?

I am new with R, and I am trying to get a custom layout. I have my CSS.
Below is my code:
ui <- fluidPage(
theme="www/style.css" ,
suppressDependencies("bootstrap"),
tags$head(includeCSS("www/styles.css")),
HTML('<nav class="navbar navbar-expand navbar-light bg-white topbar mb-4 static-top shadow">
<div id="wrapper-top">
<ul class="navbar-nav ml-auto">
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<li class="nav-item active mr-3">
<a class="nav-link acces" href="/">Link</a>
</li>
</div>
</ul>
</div>
</nav>'),
tags$footer( HTML("<footer class='sticky-footer' role='footer'>
<div class='container my-auto'>
<div class='copyright text-center my-auto'>
<span>©
2021
<a aria-label='' href=''>My footer</a>
</span>
</div>
</div>
</footer>")),
This gives me an output like this:
What I trying to achieve is to get the navigation below body tag currently it's all wrapped with this container-fluid class. And also I am trying to get the footer at the bottom of the page
Example:
Is there anyone that can help me with this? Thank you all

Bootstrap 4: Justify menu to right in navbar? [duplicate]

This question already has answers here:
Bootstrap align navbar items to the right
(24 answers)
Closed 4 years ago.
I am working with the Bootstrap 4 default navbar and I just want to add a collapsing menu that is positioned on the right, not the left, when not collapsed.
I have tried adding text-right and float-right, but neither are actually moving the menu to the right.
Here is a bootply showing the issue.
Here also is a snippet, since StackOverflow wants me to use one, though I don't think it'll be wide enough to show the non-collapsed menu:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" ></script>
<div class="navbar navbar-dark bg-dark fixed-top navbar-expand-md">
<div class="container">
<a class="navbar-brand" href="#">Brand</a>
<button type="button" class="navbar-toggler" data-toggle="collapse" data-target=".navbar-collapse">☰</button>
<div class="collapse navbar-collapse float-right">
<ul class="nav navbar-nav">
<li class="active nav-item">Home
</li>
<li class="nav-item">About
</li>
<li class="nav-item">Contact
</li>
</ul>
</div>
</div>
</div>
Add ml-auto class to ul tag containing menu
<ul class="nav navbar-nav ml-auto">
<li class="active nav-item">
Homes
</li>
<li class="nav-item">
About
</li>
<li class="nav-item">
Contact
</li>
</ul>
The element .collapse.navbar-collapse requires .justify-content-end class as it is positioned with flex (display: flex) and takes full remaining width of your navbar.
The other answers with .ml-auto are perfectly valid. The difference between these two is that .justify-content-end will make all elements inside navbar-collapse stick to the right, whereas .ml-auto will only do the same for the ones inserted after your ul.nav.nav-bar, so the ones on the left can still stick to the left. You can choose the one most appropriate to you, and feel free to combine these two for more sophisticated layouts.
Your updated Boolply can be found here.
<div class="navbar navbar-dark bg-dark fixed-top navbar-expand-md">
<div class="container">
<a class="navbar-brand" href="#">Brand</a>
<button type="button" class="navbar-toggler" data-toggle="collapse" data-target=".navbar-collapse">☰</button>
<div class="collapse navbar-collapse justify-content-end">
<ul class="nav navbar-nav">
<li class="active nav-item">Home
</li>
<li class="nav-item">About
</li>
<li class="nav-item">Contact
</li>
</ul>
</div>
</div>
</div>
add .navbar-expand-md .navbar-collapse{
flex-direction: column-reverse;} in your style sheet. thanks
.navbar-expand-md .navbar-collapse{
flex-direction: column-reverse;
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" ></script>
<div class="navbar navbar-dark bg-dark fixed-top navbar-expand-md">
<div class="container">
<a class="navbar-brand" href="#">Brand</a>
<button type="button" class="navbar-toggler" data-toggle="collapse" data-target=".navbar-collapse">☰</button>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav ml-auto"> <!-- here -->
<li class="active nav-item">Home
</li>
<li class="nav-item">About
</li>
<li class="nav-item">Contact
</li>
</ul>
</div>
</div>
</div>

I Do not want a fixed navbar

I want my navbar to scroll with the rest of the page.
I don't want any fancy style like disappearing i want it to be placed like other element of the page but i cant seem to achieve that with Bootstrap 4.
This is what it looks like:
It's hiding other elements.
<nav class="navbar navbar-expand-sm navbar-dark bg-dark" id="navbar-example">
<div class="container">
<div class="navbar-toggler" data-toggle="collapse" data-target="#menu">
<span class="navbar-toggler-icon"></span>
</div>
<div class="collapse navbar-collapse bg-dark" id="menu">
<ul class="nav ml-auto justify-content-center ">
<li>menu item 1 </li>
<li>menu item 2 </li>
<li>menu item 3 </li>
</ul>
</div>
</div>
</nav>
try adding style="position: relative !important;" to the html element.

Navbar Bootstrap allowing one item to be outside hamburger glyphicon

I have implemented a piece of code. When the browser window decrease in size (width-ways) the menu tabs enter into a clickable Hamburger glyphicon.
I would like to maintain this feature, but add one navigation tab outside the glyphicon when the browser reduces in size.
How is this possible using bootstrap? I attempted to add another
<div class="navbar"> <ul class="nav navbar-nav"> <li> </li> </ul> </div>
prior to the one ID'd "mainNavBar" however this led to poor formatting, which I thought might be able to be fixed by floating the two divs next to each other, but I couldn't work out the code to do that.
Below is my code.
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body>
<!-- Navigation bar -->
<nav class="navbar navbar-custom navbar-fixed-top">
<div class="container-fluid">
<!-- Logo -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#mainNavBar">
<span class="glyphicon glyphicon glyphicon-menu-hamburger"></span>
</button>
Markets
</div>
<!-- menu items -->
<div class="collapse navbar-collapse" id="mainNavBar">
<ul class="nav navbar-nav navbar-right">
<li> About Us
</li>
<li> News
</li>
<li> Analysis
</li>
<li> Random Article
</li>
<li> Contact Us
</li>
</div>
</nav>
<!-- End Navigation Bar -->
</body>
</html>
Bootply: http://www.bootply.com/Vky1AGlU5F
CSS:
.still_on_view{
float: right;
}
HTML:
<nav class="navbar navbar-custom navbar-fixed-top">
<div class="container-fluid">
<!-- Logo -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#mainNavBar">
<span class="glyphicon glyphicon glyphicon-menu-hamburger"></span>
</button>
<ul class="still_on_view nav navbar-nav">
<li> About Usb2
</ul>
Markets
</div>
<div>
</div>
<!-- menu items -->
<div class="collapse navbar-collapse" id="mainNavBar">
<ul class="nav navbar-nav navbar-right">
<li> About Us
</li>
<li> News
</li>
<li> Analysis
</li>
<li> Random Article
</li>
<li> Contact Us
</li>
</div>
</nav>

Cannot get navbar right links to float right

I am a newbie and cannot figure out how to get my links to float to the right:
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">
<img alt="Brand" src="...">
</a>
<ul class="navbar-right">
<li>Home</li>
<li>About Me</li>
<li>Get in Touch</li>
</ul>
</div>
</div>
Can someone please help me figure this simple task out?
Try below code
<nav class="navbar navbar-default">
<div class="container-fluid">
<a class="navbar-brand" href="#">
<img alt="Brand" src="...">
</a>
<ul class="nav navbar-nav navbar-right">
<li>Home</li>
<li>About Me</li>
<li>Get in Touch</li>
</ul>
</div>
</nav>
Take a look at the example "Right-Aligned Navigation Bar" of Right Navigation
Right navigation is aligned by changing
class="nav navbar-nav" to class="nav navbar-nav navbar-right"
Hope this helps you.

Resources