not show active tab title correctly in AngularStrap tab

心不动则不痛 提交于 2019-12-01 12:30:01

问题


I have four tabs using the latest AngularStrap tab, every tab has a close button, and every tab pane using the latest ui-grid.

  1. expected result: close the second tab, then show the third active tab, which can show the third tab title and tab pane correctly.
  2. but the actual result is: close the second tab, then show the third tab pane correctly, the third active tab title can't show correctly, it show the fourth active tab title.

html code:

        <div data-fade="1" bs-active-pane="tabs.activeTab" bs-tabs>
            <div ng-repeat="tab in tabs" data-title="{{ tab.title }}" name="{{ tab.title }}" disabled="{{ tab.disabled }}" ng-include src="tab.page" bs-pane></div> 
        </div>

js code:

    // delete tab
    closeTab = function(obj){
        var index = obj.parentElement.dataset.index;
        // remove your selected tab
        $rootScope.tabs.splice(index, 1);
        if(!angular.isUndefined($rootScope.tabs[index])){
            // show the next active tab title.
            $rootScope.tabs.activeTab = $rootScope.tabs[index].title;

        }

    }

can anyone help me? thank u very much!


回答1:


When you splice from the array the indices change because the element is removed so $rootScope.tabs.activeTab = $rootScope.tabs[index].title; doesn't align anymore;



来源:https://stackoverflow.com/questions/34203064/not-show-active-tab-title-correctly-in-angularstrap-tab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!