虽然这是一个迟到的帖子,但它可能会对某人有所帮助。我在 angularjs 的指令中使用了引导向导。
.directive('rootwizard', function($route){
return {
require : '?^ngModel',
link: function(scope, element, attrs, ngModel){
element.bootstrapWizard({
onTabClick: function(tab, navigation, index) {
return false;
},
onNext: function(tab, navigation, index) {
return false;
},
onPrevious: function(tab, navigation, index){
return true;
},
onTabShow: function(tab, navigation, index) {
ngModel.$setViewValue(index);
ngModel.$render();
}
});
}
};
})
html代码::
<div id="rootwizard" rootwizard ng-model="curIndex">
<div class="navbar">
<div class="navbar-inner">
<div class="container">
<ul class="nav nav-pills nav-wizard">
<li>
<a href="#tab1" class="long" data-target="#tab1" data-toggle="tab"> Tab1</a>
<div class="nav-arrow"></div>
</li>
<li>
<div class="nav-wedge"></div>
<a href="#tab2" class="long" data-target="#tab2" data-toggle="tab"> Tab2</a>
<div class="nav-arrow"></div>
</li>
<li>
<div class="nav-wedge"></div>
<a href="#tab3" class="long" data-target="#tab3" data-toggle="tab"> Tab3</a>
<div class="nav-arrow"></div>
</li>
<li>
<div class="nav-wedge"></div>
<a href="#tab4" class="long" data-target="#tab4" data-toggle="tab"> Tab4</a>
<div class="nav-arrow"></div>
</li>
<li>
<div class="nav-wedge"></div>
<a href="#tab5" class="long" data-target="#tab5" data-toggle="tab"> Tab5</a>
<div class="nav-arrow"></div>
</li>
</ul>
</div>
</div>
</div>
<div class="tab-content">
<div class="tab-pane wave" id="tab1">
1
</div>
<div class="tab-pane wave" id="tab2">
2
</div>
<div class="tab-pane wave" id="tab3">
3
</div>
<div class="tab-pane wave" id="tab4">
4
</div>
<div class="tab-pane wave" id="tab5">
5
</div>
<ul class="pager wizard">
<li class="previous" ><a href="" id="prebtn" ng-click="getPreviousTab(curIndex)">Previous</a></li>
<li class="next" ><a href="" id="nxtbtn" ng-click="getNextTab(curIndex)">Next</a></li>
</ul>
</div>
</div>
在控制器中添加以下代码:
scope.curIndex = 0;
scope.getPreviousTab = function(id){
angular.element('[data-target="#tab'+id+'"]').tab('show');
}
scope.getNextTab = function(id){
var nextTabVal = id + 1;
angular.element('[data-target="#tab'+nextTabVal+'"]').tab('show');
}
这对我很有用。希望它可以帮助某人!