How do I select a dynamically loaded tab?


Hi, I have recently gotten into ionic and I am already in love. It’s great. I was wondering if anyone can assist me with a small query. I have made an app to load reddit /r/funny subreddit, it’s going well, I have used tab navigation but I am having trouble as I dynamically load the full tab in, once it has loaded I would then like to select it, I have looked into

$scope.$on('$viewContentLoaded',function() {

However this throws a nice little error informing me that the tab does not exist. Or it simply does not do anything. I have made sure to check what the first tab index is (1). I have no idea what to do. Thanks for your help


Hmm, with out seeing an example to try and work with, maybe try wrapping things with a $timeout. This way, things have a chance to load and compile.

$scope.$on('$viewContentLoaded',function() {


I Tried this before, tragically it didn’t work, it gave me this lovely error

TypeError: Cannot read property 'navViewName' of undefined
    at (http://localhost:8080/lib/ionic/js/ionic.bundle.js:39966:31)
    at http://localhost:8080/lib/ionic/js/ionic.bundle.js:35952:41
    at Array.forEach (native)
    at delegate.(anonymous function) [as select] (http://localhost:8080/lib/ionic/js/ionic.bundle.js:35951:19)
    at http://localhost:8080/js/app.js:24:27
    at http://localhost:8080/lib/ionic/js/ionic.bundle.js:21691:28
    at completeOutstandingRequest (http://localhost:8080/lib/ionic/js/ionic.bundle.js:11901:10)
    at http://localhost:8080/lib/ionic/js/ionic.bundle.js:12202:7

If you would like more background here is where the process takes place

var reddit = angular.module('reddit', ['ionic', 'ngCordova'])
.config(function($stateProvider, $urlRouterProvider) {
	    .state('view', {
			url: '/r/:id',
	        templateUrl: 'templates/img.html',
	        controller: function($scope, $stateParams, $ionicTabsDelegate, $ionicModal, $timeout) {
	        	$ = window.scope[$]
				$scope.$on('$viewContentLoaded',function() {

I have no idea what I can do to solve this, thanks for your help.


Hmm, any chance you could create a demo of this in a git repo? I think I know what can be done but without see the whole thing I can’t be sure.


Here’s everything I have


Any ideas? I am really stuck.