my issue here is that i have a component that has functions that i want my app.component.html to have access to
book.component.html
<div class="form-inline">
<input id="inputSearchBar" class="form-control mr-sm-2" type="text" placeholder="Search" [(ngModel)]="Text">
<button class="btn btn-outline-info my-2 my-sm-0" type="submit" (click)="onSearch()">Search</button>
</div>
Now this is currently working because i have this line of code on my book.component.html, what i want is to use this on my app.component.html inside the navbar
app.component.html
<header>
<nav class="navbar navbar-toggleable-md navbar-inverse bg-inverse">
<button class="navbar-toggler navbar-toggler-right" type="button"
data-toggle="collapse"
aria-controls="navbarColor01"
aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="#">Navbar</a>
<div class="collapse navbar-collapse" id="navbarColor01" >
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#" [routerLink]="['']">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#" [routerLink]="['about']">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#" [routerLink]="['books']">Books</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#" >Register</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#" [routerLink]="['login']">Login</a>
</li>
</ul>
</div>
</nav>
</header>
I want to have that searchbox as part of my navbar and it being functional, what should i add on my components or what should i do to make it work.
you can use parent and child relation ship here. create component for search bar and add in the Parent component.
1)
create search component like this
#Component({
selector: 'search-component',
})
export class searchcomponent { }
2) Add in the parent HTML
app.component.html
<header>
<search-component> </search-component>
</header>
More info check this link https://angular.io/docs/ts/latest/cookbook/component-communication.html
You can use service for this task:
https://angular.io/docs/ts/latest/cookbook/component-communication.html#!#bidirectional-service
Related
I want my navbar to be the exact layout I have now, but when the navbar is collapsed I want the searchbar between the logo and toggle button, is there anyway to keep the remaining layout but still put the search bar between?
<nav class="navbar navbar-expand-lg" style="background-color: #121212">
<div class="container-fluid">
<a class="navbar-brand" href="#">Narton</a>
<button
class="navbar-toggler"
type="button"
data-bs-toggle="collapse"
data-bs-target="#navbarNavAltMarkup"
aria-controls="navbarNavAltMarkup"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#">Albums</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Artists</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Discover</a>
</li>
</ul>
<form class="d-flex w-100 p-2" role="search">
<input
type="text"
class="form-control"
placeholder="Search"
aria-label="Search"
aria-describedby="basic-addon1"
/>
</form>
<button type="button" class="btn btn-outline-secondary py-2">Login</button>
<ul class="navbar-nav sm-icons">
<a class="nav-link" href="https://twitter.com/"><i class="bi bi-twitter"></i></a>
<a class="nav-link" href="#"><i class="bi bi-instagram"></i></a>
<a class="nav-link" href="#"><i class="bi bi-tiktok"></i></a>
<a class="nav-link" href="#"><i class="bi bi-facebook"></i></a>
</ul>
</div>
</div>
</nav>
this is the html code for my navbar
css code for my Navbar (I only put in what I thought was necessary)
.sm-icons {
flex-direction: row;
}
.sm-icons .nav-link{
padding-right: 1em;
}
I built a header using bootstrap. But, when I use a inner stylesheet on that page for other elements the dropdown has a glitch. Doing Upper lower bootstrap CDN or jQuery CDN link doesn't fix my problem. Header only works whenever there is not inner stylesheet or external stylesheet link. How can I solve this problem?
This is the problem I am facing right now
via GIPHY
Please try this code, TO Bootstrap dropdown giving glitch with inner CSS style
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.13.0/umd/popper.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarColor01" aria-controls="navbarColor01" aria-expanded="false" aria-label="Toggle navigation" style="">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarColor01">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="text" placeholder="Search">
<button class="btn btn-secondary my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
I hope this code will be useful to you.
Thank you.
A MVC 5 project was created and you want to change the menu of this one, for it resorted to Bootwatch, the menu that you want to implement is the following
The first thing I did was change the general style of my project, download the bootstrap.css file
and then I replaced it with my BundleConfig because of the previous one I had, this modifies the style of my project, but does not include the aforementioned navbar
To put the Navbar that you want, implement the following code in my _Layout.cshtml:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>#ViewBag.Title - Muebles Pangal</title>
#Styles.Render("~/Content/css")
#Scripts.Render("~/bundles/modernizr")
</head>
<body>
<div class="container">
<nav class="navbar navbar-expand-lg navbar-dark bg-success">
<a class="navbar-brand" href="#">Muebles Pangal</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarColor01" aria-controls="navbarColor01" aria-expanded="false" aria-label="Toggle navigation" style="">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarColor01">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#Url.Action("Index", "Categorias")">Categorias </a>
</li>
<li class="nav-item">
<a class="nav-link" href="#Url.Action("Index", "Productoes")">Productos </a>
</li>
<li class="nav-item">
<a class="nav-link" href="#Url.Action("Index", "Ubicacions")">Proveedores </a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" placeholder="Buscar" type="text">
<button class="btn btn-secondary my-2 my-sm-0" type="submit">Buscar</button>
</form>
</div>
</nav>
</div>
<div class="container body-content">
#RenderBody()
<hr />
<footer>
<p>© #DateTime.Now.Year - Sistema Bodega</p>
</footer>
</div>
#Scripts.Render("~/bundles/jquery")
#Scripts.Render("~/bundles/bootstrap")
#RenderSection("scripts", required: false)
</body>
</html>
But when executing my project I find the following problem, my menu does not work in a good way to the responsive call, this means that when I change (shrink) the size of my browser and call the menu from my <span class = "navbar- toggler-icon "> </ span> this is displayed, but it immediately collapses again.
So it does not work in the right way, I've been trying to solve this for days but I have not had good results.
I have installed the Bootstrap and Bootstrap.less packages, could someone help me? what's going on?
any help for me?
You are missing jQuery.min.js i believe, or it might be placed in the wrong order in your code structure. Hope this snippet helps!!
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-expand-lg navbar-dark bg-success">
<a class="navbar-brand" href="#">Muebles Pangal</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarColor01" aria-controls="navbarColor01" aria-expanded="false" aria-label="Toggle navigation" style="">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarColor01">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#Url.Action(" Index ", "Categorias ")">Categorias </a>
</li>
<li class="nav-item">
<a class="nav-link" href="#Url.Action(" Index ", "Productoes ")">Productos </a>
</li>
<li class="nav-item">
<a class="nav-link" href="#Url.Action(" Index ", "Ubicacions ")">Proveedores </a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" placeholder="Buscar" type="text">
<button class="btn btn-secondary my-2 my-sm-0" type="submit">Buscar</button>
</form>
</div>
</nav>
Can you check your css for the following:
.navbar-collapse.collapse {
display: none!important;
}
I am able to get a working menu in a new MVC 5 project using what you posted, but I do not have the same css as you.
Please see a similar problem: Bootstrap mobile menu wont stay open
I'm using a bootstrap navbar with a dropdown for the user menu.
The issue
I'm using this navbar as a blade template in laravel. On some pages the dropdown menu has the dimensions 160x63.39px and on some other pages 160x49px.
But the source code is the same on every page.
Does anybody know what reasons this issue could have?
Source
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<a class="navbar-brand" href="http://127.0.0.1">Tool</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbar">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="http://127.0.0.1/dashboard">Dashboard</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown">Ticketsystem</a>
<div class="dropdown-menu">
<a class="dropdown-item" href="http://127.0.0.1/tickets/new">Neues Ticket</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="http://127.0.0.1/tickets">Alle Tickets</a>
</div>
</li>
</ul>
<ul class="navbar-nav ml-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown" aria-expanded="false">User</a>
<div class="dropdown-menu">
<form action="http://127.0.0.1/logout" method="post">
<input type="hidden" name="_token" value="#CSRF_TOKEN#">
<button type="submit" class="dropdown-item">Logout</button>
</form>
</div>
</li>
</ul>
</div>
</div>
</nav>
This is because different browsers have default CSS on some elements.
Best way to remove this is to add this CSS to your code:
* {
margin: 0;
padding: 0;
}
Or to use necolas.github.io/normalize.css
I have problems with implementing a bootstrap header in my code, but I think it's not my fault, but I dont know how to fix it.
The nav menu is always in phone view or something. I put my code in a JSFiddle so you guys can see my problem :
Here's the link: https://jsfiddle.net/wx86vq2y/2/
and I got a screenshot like how it had to be: https://gyazo.com/aca2e255638350dc386812ea9878ecfe . Does somewhone know what is wrong? I cant solve this problem at this moment.
<nav class="navbar navbar-toggleable-md navbar-light bg-faded">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarTogglerDemo01">
<a class="navbar-brand" href="#">Dize Design AOS-Header v.2</a>
<ul class="navbar-nav mr-auto mt-2 mt-lg-0">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Project</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About Us</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="text" placeholder="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
you can solve it by replacing the beta version bootstrap 4 css to bootstrap 3 css bootstrap3 url
Please check the sample