How to integrate bootstrap template in angular 2
First open command prompt (CMD) and type following command
change default directory to your coding repository like D:\angular_projects
please click below link to setup angular project in your local system
Click Here
please type the 'cd myproject' in command prompt and type 'ng serve'
after that please open following url 'http://localhost:4200/' in your browser
please follow below steps to integrate bootstrap in angular
Step 1:
please copy and paste the following script in head part in 'src/index.html'
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"></link> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style> /* Remove the navbar's default margin-bottom and rounded borders */ .navbar { margin-bottom: 0; border-radius: 0; } /* Set height of the grid so .sidenav can be 100% (adjust as needed) */ .row.content {height: 450px} /* Set gray background color and 100% height */ .sidenav { padding-top: 20px; background-color: #f1f1f1; height: 100%; } /* Set black background color, white text and some padding */ footer { background-color: #555; color: white; padding: 15px; } /* On small screens, set height to 'auto' for sidenav and grid */ @media screen and (max-width: 767px) { .sidenav { height: auto; padding: 15px; } .row.content {height:auto;} } </style>Step 2:
please open your app.component.html and paste the following code in your directory 'app/app.component.html'
<nav class="navbar navbar-inverse"> <div class="container-fluid"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#">Logo</a> </div> <div class="collapse navbar-collapse" id="myNavbar"> <ul class="nav navbar-nav"> <li class="active"><a routerLink="/">Home</a></li> <li><a routerLink="/aboutus">About</a></li> </ul> </div> </div> </nav> <div class="container-fluid text-center"> <div class="row content"> <div class="col-sm-2 sidenav"> <p><a href="#">Link</a></p> <p><a href="#">Link</a></p> <p><a href="#">Link</a></p> </div> <div class="col-sm-8 text-left"> <h1>Home Page</h1> <p>Home Page Text..</p> <hr> <h3>Test</h3> <p>Lorem ipsum...</p> </div> <div class="col-sm-2 sidenav"> <div class="well"> <p>ADS</p> </div> <div class="well"> <p>ADS</p> </div> </div> </div> </div> <footer class="container-fluid text-center"> <p>Footer Text</p> </footer>
Note: This is basic bootstrap setup and change as per your requirement like menucomponent, homecomponent.. etc.
please check your browser
No comments: