以下是我的控制器代码
app.controller('testCtrlr', function ($scope, $http, $timeout) {
$scope.currentTab = [];
var tabs = [{
"ID": $scope.AddedWorkFlowTabs++,
"Name": "Step " + $scope.StepCount++,
"Customizations": { QuestionGroups: [] }
}],
IsSameNameTab = false,
selected = null,
previous = null;
$scope.tabIndex = 0;
$scope.tabs = tabs;
$scope.selectedIndex = 0;
$scope.onTabChanges = function (tabIndex) {
//you can add some loading before rendering
$scope.tabIndex = tabIndex;
$scope.currentTab = $scope.tabs[tabIndex];
};
$scope.addTab = function (title, view) {
debugger;
//angular.forEach(tabs, function (tb, key) {
// if (tb.Name == title) {
// IsSameNameTab = true;
// showToastrMessage('error', 'You cannot create a step with same name.!');
// }
//});
if (!IsSameNameTab) {
$scope.WorkFlow = {
"ID": $scope.AddedWorkFlowTabs++,
"Name": "Step " + $scope.StepCount++,
"Customizations": { QuestionGroups: [] }
}
$scope.tabs.push($scope.WorkFlow);
$scope.activeTabIndex = ($scope.tabs.length - 1);
$scope.currentTab = $scope.WorkFlow;
$scope.tabIndex = $scope.tabs.length - 1;
}
IsSameNameTab = false;
};
$scope.removeTab = function (index) {
//var index = $scope.tabs.indexOf(tab);
$scope.tabs.splice(index, 1);
};
});
以下是我的cshtml代码
<div class="container" ng-controller="testCtrlr">
<tabset>
<tab sortable-tab ng-repeat="tab in tabs" ng-click="onTabChanges($index)" active="activeTabIndex">
<tab-heading>
{{tab.Name}}
<a ng-click="removeTab($index)" ng-href=""><i class='fa fa-2x fa-close' ng-hide="tabs.length==1"></i></a>
</tab-heading>
</tab>
<tab-heading>
<i class="fa fa-2x fa-plus" ng-click="addTab(tTitle)"></i>
</tab-heading>
</tabset>
</div>
我正在使用angularjs 1.6.3和bootstrap 3.0.0以及最新版本的angular bootstrap选项卡。我的问题是选项卡上的关闭图标有时在活动选项卡上不起作用,并且不会调用删除Tab方法i-e ng-click有时不会触发活动选项卡关闭图标。如果有人能告诉我它到底是什么,我会很高兴的。谢谢。