$ionicTabsDelegate isn't there


Hello guys. I’m using the latest version, i have included ‘ionic’ as dependency injection and other things like $ionicPopup work. So my question is, why doesn’t it do anything? if i put it like this : ,alert($ionicTabsDelegate)" it say ,object Object". If i use the .select method it doesn’t work. This is how it looks

And this is where i’m calling them, and the list goes on to opening more ion tab tags, until the ion tabs closes encapsulated by the div with the randomTabsController

So, tell me why doesn’t it work ?


If you use alert({}); it will output object Ojbect as well, that is simply the string representation of any object in javascript :slight_smile: Try outputting it with a console.log, it will actually output your treeview.

I’m not sure about the tabbardelegate, but are you sure the randomnumber is actually an existing index?


yeh i checked the randomnumber via alert,and i have 4 tabs,always generates correct number.I will try console.log asap


Console.log($ionicTabsDelegate) doesn’t show anything…not even an error,but i figure if it detects the object, why is there an error in executing it’s property, that’s ver weird


Try using a $timeout on your $ionicTabsDelegate.select() function.


Ah, that would be it! Probably not the $timeout function does the trick, but the $apply function that it wraps under the hood.

So basically, this should work

$scope.randomnumber = Math.round( Math.random()*3);

Give this a try :smiley:


Not sure if that’s the reason, but I know from experience that wrapping it in a $timeout works. Timeout length seems to be unimportant- 100ms should be plenty.


Not terribly happy with this solution by the way- always seemed like a hack. If wrapping it in $apply works too, maybe that’s a cleaner way to go about it.

Even though I think Ionic should support it without $apply or a $timeout, but just out of the box IMHO


Solved - Wrapping it in a 100ms timeout worked for me. Damn, they should fix these things or make people pay more attention. You can lose days of work if you have intertwined multiple things like this that don’t work and you have to develop ways to test them separately :(. Thank you guys, i really apreciate you helping me out.All love


Well, angular usually wraps stuff like this on ng-clicks etc… So it shouldn’t really be a problem… But still worth the try I guess. Maybe somewhere is a race condition that requires the asynchornous timeout after all, not sure.

@mocanumarius951 did it work with $scope.$apply instead of $timeout as well?


only with $timeout , i tried to wrap on $scope.apply(…) , not put a $scope.$apply() at the end of the function tho. Don’t know how that works out


Opened up an issue: https://github.com/driftyco/ionic/issues/2301

Has a Codepen which describes the problem also: