1

I have a webview template which loads data from a link. So, if I have to load a separate webview I use the same template and controller and change the link. It works fine for most cases. However, if I try to load a different webview from the current one it does not work. The reason is that the controller is not triggered again as we are loading the same view. I tried navigating a different page and then moving to webview template, however the result is the same the controller is not initialised. How can I trigger the controller or have the controller reload?

I tried setting cache to false globally and setting reload to true however it still does not reload the controller. Here is how my code looks

.state('webView', {
            url: '/webView',
            cache: false,
            templateUrl: 'templates/webView.html',
            controller: 'WebViewCtrl',
            reload: true
        });

I have also set

$ionicConfigProvider.views.maxCache(0);

However, my controller still refuses to reload. Any ideas on what am missing?

jsdev
  • 101
  • 7
  • did you try `init()` angular method??? – SakthiSureshAnand Dec 28 '15 at 12:51
  • Am not sure I understand what exactly you mean. I haven't used the init() method. Can you explain in a bit more detail what exactly you are hinting at? – jsdev Dec 28 '15 at 13:32
  • http://stackoverflow.com/questions/15458609/execute-function-on-page-load (please look at this link) – SakthiSureshAnand Dec 28 '15 at 13:34
  • tried all the solutions listed there no luck :( I guess the callbacks wouldn't work because in my case the view is not loaded again as such nor does the route change. Am basically navigating from same view to same view. – jsdev Dec 28 '15 at 14:05

1 Answers1

0

Finally ended up using state transition mentioned in this link - https://github.com/angular-ui/ui-router/issues/582.

    $state.transitionTo($state.current, $stateParams, { reload: true, inherit: false, notify: true });

This did the trick for me and reloaded my view and the controller.

jsdev
  • 101
  • 7