这里我使用如下所示的Angular和Bootstrap导航选项卡
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#home">Home</a></li>
<li><a data-toggle="tab" ng-click="getProjectEnquiries()" href="#menu1">Menu 1</a></li>
</ul>
<div class="tab-content">
<div id="home" class="tab-pane fade in active">
<h3>HOME</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
<div id="menu1" class="tab-pane fade">
<h3>Menu 1</h3>
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
<div id="menu2" class="tab-pane fade">
<h3>Menu 2</h3>
<p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam.</p>
</div>
<div id="menu3" class="tab-pane fade">
<h3>Menu 3</h3>
<p>Eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.</p>
</div>
</div>
</div>
当我单击“特殊”选项卡时,“打开”但我需要以编程方式打开它,所以我应该如何执行
$scope.getProjectEnquiries = function () {
//How can I open that Tab
}
答案 0 :(得分:0)
您可以使用angular.element
添加类并触发选项卡窗格
$scope.getProjectEnquiries = function (element, $event) {
//remove current active classes
angular.element(document.querySelector(".active.show")).removeClass("active").removeClass("show");
//adding active class so current tab will be active
var myEl = angular.element(document.querySelector(element));
myEl.addClass('active show');
//adding class to li too
var anchorElement = angular.element($event.target.parentNode);
anchorElement.addClass('active')
}
您可以在此处查看代码和演示