How can I make my Ionic Button refresh all ion-views. (Preferable in most just revaluate a ng-switch) How can I make my Ionic Button refresh all ion-views. (Preferable in most just revaluate a ng-switch) angularjs angularjs

How can I make my Ionic Button refresh all ion-views. (Preferable in most just revaluate a ng-switch)


This doesn't seem to be ionic specific nor ng-switch specific, but seems to be ui-router specific. If I understand correctly, you want to refresh your view when you click your button and execute some data logic on Teams. I see this here

$state.go($state.current);

However, this simply won't do it for you because since your path has not changed your controller will not re-run. However, $state.go() offers additional parameters, including one we need for just this - reload. Try the following...

$state.go($state.current, {}, { reload: true }); //second parameter is for $stateParams

This will refresh your views and re-run your controller, so you'll see this reflected in the UI. See $state.go(to [, toParams] [, options]) docs for more information


Furthermore, if you and others would like to see this in action I have crafted two simplistic examples. The code here is by no means best-practice driven, but is indeed self-descriptive enough to demonstrate the core issue and solution.

JSFiddle Example - working - using $state.go($state.current, {}, { reload: true });

JSFiddle Example - not working - using only $state.go($state.current);