-
Notifications
You must be signed in to change notification settings - Fork 6.7k
ub-tabaset does not select most recently added tab #5656
Comments
It is not a bug. When you add a tab. It will render the view, and in the mean time the active being updated. You have to let the render view finish its job first. Then set the vm.activeTab By: That'll work |
I was having the same issue and lunhat79's solution worked for me. What do you think about adding an example to the docs that show how to programmatically add tabs? Two flavors would be ideal, one with a button as being used here and one using the last tab as the trigger to add additional tabs. |
Closing as a usage issue. |
It is just the MVVM working flow. I am facing the problem as |
@lunhat79 , thanks, yea I ended up with a similar workaround as you suggested above, and that works for me. I still think it is a bug though @wesleycho . I am not a directives expert, but in this specific case, it seems that we always want to trigger Currently, I am guessing that this behaviour (bug) was introduced when the |
@lunhat79 , thanks for the workaround. I prefer to use $timeout in stead of $interval as I only need to delay the execution just once. Not a big deal, I guess. Ex:
Replace the code
vm.activeTab=vm.counter;
By:
var curIndex = vm.counter;
$timeout(function() {
vm.activeTab = curIndex;
}, 0); I agree that either this should be classified as bug and need to fix it, Or we should have updated example which mentions this usage (workaround) |
Thanks everybody. You save my day. |
Just remark: |
Hi, This got close, but I really don't like the solution. It's definitely not clean because it's a race condition you are trying to win with an interval or timeout. edit : with a controller that manage my activeId. I can now add dynamically tab and set them active in my angular code. |
add index of each tab inside the ng-repeat |
Bug description:
uib-tabset.active becomes null after addTab calls, when I attempt to add a new tab, and also make it the active tab
See https://plnkr.co/edit/sJ6aNyPbN609toafgHx2?p=preview
HTML
script.js
Angular: 1.5.1
UIBS: 1.2.4
The text was updated successfully, but these errors were encountered: