从AngularUI选项卡中删除选项卡

时间:2015-06-03 12:23:11

标签: angularjs twitter-bootstrap tabs angular-ui angular-ui-bootstrap

我想删除AngularUI的tabset / tab指令中的标签。 奇怪的是,标签内容被删除了,但不是标签......真的丢失了。

我已经举了一个例子来展示正在发生的事情:

这是关键部分:

// Code is taken 1:1 from https://github.com/angular-ui/bootstrap/blob/master/src/tabs/tabs.js
ctrl.removeTab = function removeTab ( tab ) {
        var index = tabs.indexOf( tab );
        //Select a new tab if the tab to be removed is selected and not destroyed
        if ( tab.active && tabs.length > 1 && !destroyed ) {
            //If this is the last tab, select the previous tab. else, the next tab.
            var newActiveIndex = index == tabs.length - 1 ? index - 1 : index + 1;
            ctrl.select( tabs[newActiveIndex] );
        }
        tabs.splice( index, 1 );
        console.log( 'tabs after removing: ', tabs );        
    };

发生了什么: 正在删除选项卡内容,但不删除选项卡。

https://jsfiddle.net/stefanwalther/k9n17609/6/

1 个答案:

答案 0 :(得分:-1)

您只删除数组中的选项卡,但html中的选项卡不是通过ng-repeat或类似的角度渲染的,并且没有绑定到数组中的选项卡。

相关问题