1

The following is my ui-router configuration. I hope that the child controller will be executed when I change the child state every time. But now, the child controller be executed only the first time I change the child state.

Is someone could help me?

 $stateProvider
    .state('tab', {
        url: '/tab',
        abstract: true,
        templateUrl: 'views/tabs.html'
    })
    .state('tab.order-foods',{
        url:'/order-foods',
        views:{
            'tab-order-foods':{
                templateUrl:'../views/tab-order-foods.html',
                controller:'orderFoodsCtrl'
            }
        }
    })
    .state('tab.cart',{
        url:'/cart',
        views:{
            'tab-cart':{
                templateUrl:'../views/tab-cart.html',
                controller:'cartCtrl'
            }
        }
    })
    .state('tab.orders',{
        url:'/orders',
        views:{
            'tab-orders':{
                templateUrl:'views/tab-orders.html',
                controller:'ordersCtrl'
            }
        }
    })
    .state('tab.mine',{
        url:'/mine',
        views:{
            'tab-mine':{
                templateUrl:'views/tab-mine.html',
                controller:'mineCtrl'
            }
        }
    });
$urlRouterProvider.otherwise('/tab/order-foods');

1 Answer 1

0

Check these:

And you will see, that ionic does cache all the stuff for us. To avoid we can

  • avoid caching by cache: false,
  • disable caching with $ionicConfigProvider.views.maxCache(0);
  • or keep caching as is, and let controller be executed only once ... while doing some smart stuff during these View LifeCycle and Events
Sign up to request clarification or add additional context in comments.

2 Comments

It works by following your comments, thanks very much.
Great to see that! Enjoy ionic, sir ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.