This is a migrated thread and some comments may be shown as answers.

Angular get selected tab index on compile/load/select returns -1

2 Answers 427 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 04 Aug 2014, 12:10 PM
So, I am upgrading to the latest kendo.all package (2014.2.716) and code that was previously working with angular-kendo.js is now failing.  The setup we have is a main tab container with a set of tabs and each tab points to a templateUrl.  When the templateUrl is loaded, I check the currently selected tab and get its index and pull out configuration information from the tab datasource.

The new code compiles the templateUrl prior to completing the tab.select() so if I try to pull out tab.select().index() it returns a -1.  Clearly this method will not work.  Is there a preferred way to get the currently selected tab configuration when that templateUrl is compiled.  If I put in a timeout of 500ms, the select().index() returns as it did before, but I would prefer not to stick my page with timeout's.

Code prior was like this:

var tabStrip =  $scope.$parent.vm.kendoTabStrip;
vm.tabDataSource = $scope.$parent.vm.kendoTabStrip.dataSource.at(tabStrip.select().index());   // now tabStrip.select().index() returns - 1
vm.template = vm.tabDataSource.template;  // contains configuration, and no i don't want to retrieve it on this html page as it is dynamic 

Let me know what my options are here, thanks.

2 Answers, 1 is accepted

Sort by
0
Andrew
Top achievements
Rank 1
answered on 04 Aug 2014, 01:23 PM
If anyone cares, my workaround was adding a k-on-select event and setting the selected index of the tab on the scope.  Then read the selected index from the parent scope.

parent tab container:
  vm.tabStripSelect = function (e) {
            var selectedIndex = $(e.item).index();
            vm.selectedTabIndex = selectedIndex;
        };

child template:
vm.tabDataSource = $scope.$parent.vm.kendoTabStrip.dataSource.at($scope.$parent.vm.selectedTabIndex);



0
Mihai
Telerik team
answered on 06 Aug 2014, 10:51 AM
Hi Tom,

I pushed a fix that restores the previous behavior.  It will be available in the next build.

Regards,
Mihai
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
TabStrip
Asked by
Andrew
Top achievements
Rank 1
Answers by
Andrew
Top achievements
Rank 1
Mihai
Telerik team
Share this question
or