问题描述
我已经使用npm安装程序在我的angular 4项目中安装了bootstrap 3.我已经完成了一个基本站点,并且正在尝试获取一个动态的sideNav栏,该栏可以进出.
I have installed bootstrap 3 in my angular 4 project using the npm installer. I have a basic site done up and am trying to get an dynamic sideNav bar that will toggle in and out.
我在网上看到了一些示例,但是无论它是引导程序的较新版本还是与angular的兼容性问题,它们似乎都不起作用.
I have seen some examples online however they do not seem to work whether it be a newer version of bootstrap or compatibility issues with angular.
有人对我在这种情况下可以使用的导航栏有什么建议吗?
Does anyone have any recommendations for a navigation bar that I could use in this instance?
我的app.component.html
中的HTML:
<!-- Sidebar -->
<script src="src/Javascript/sidebar.js"></script>
<nav class="navbar navbar-inverse navbar-fixed-left" id="sidebar-wrapper" role="navigation">
<ul class="nav sidebar-nav">
<li class="sidebar-brand">
<a href="#">
Brand
</a>
</li>
<li>
<a href="#">Home</a>
</li>
<li>
<a href="#">About</a>
</li>
<li>
<a href="#">Events</a>
</li>
<li>
<a href="#">Team</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
Works <span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li><a href="#">About</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Clients</a></li>
<li><a href="#">Contact</a></li>
</ul>
</li>
<li>
<a href="#">Services</a>
</li>
<li>
<a href="#">Contact</a>
</li>
</ul>
</nav>
推荐答案
首先,您需要导入bootstrap 3或使用Bootstrap 3 CDN
First You need to Import bootstrap 3 or Use Bootstrap 3 CDN
然后代替使用JQuery使用指令来操纵侧边栏的类和样式
Then Instead of using JQuery Use Directive to manipulate Class and Style of Side Bar
我已经在不使用JQuery的情况下为同一侧栏创建了堆栈闪电战,请检查以下内容: https://stackblitz.com/edit/angular-z6hrob
I Have Created Stack blitz for same side Bar without using JQuery Check this: https://stackblitz.com/edit/angular-z6hrob
这篇关于垂直侧面导航栏-Angular 4和Bootstrap 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!