View Still Not Refreshing

This is still breaking my balls, I have a view that needs to be navigated to on an ng-click so I call my small function in the html like this

<button ng-click="goToView('home')">(Cancel) Back to home</button>

My simple function is as follows

$scope.goToView = function(view){
	//$window.location.href = view;

	$state.go(view, {}, {reload:true});

Now from what I read this simple line should do the trick, you will notice the $window bits of code commented out that works but it reloads the entire file and basically all the scripts again which is really slow. Someone please help a brother out

You could use this in your view controller

$scope.$on('$ionicView.enter', function() { "your code" });

This will run the code every time the page is opened.

@Chaos505 Hi I tried your code but can you be specific and tell me what should go in the “your code” section

In your routing file you need to set cahe:false for that particular route.

Hi I’ve tried that in the routing and the views itself and that did not resolve the problem

Try this link

In you view controller
For example
module.controller('HomePageCtrl',function ($scope, $state) { $scope.$on('$ionicView.enter', function() { }); });

the “your code” is what every you want to run when the page comes into view

@Chaos505 @rajeshwarpatlolla @codinghorror ok guys this is what I have simplicity but I seem to be on to something what I did was put the views into different divs and specified the cache-view=“false” on my home view here is my function now

	$scope.goToView = function(view){
		//$window.location.href = view;


So what happens is the code works accordingly but then the previous view is loaded again for some reason when the $window.location.reload(); line is done, if I remove that line the home view appears very briefly and the previous is loaded any ideas?

to hang in there --> why do you want to refresh a view? what is your intention…

if you opened the view you are navigating to was opened before it is cached. And your controller is not executed again.
In this case … like some users correctly answered to use the ionicView events

–> if you reenter that cached view (you are navigating to) you can listen in that states controller on $ionicView.enter --> and there you can execute code, that you controller should do when it is loaded.

Hi I am working in an app where users can enter expenses which are initially saved in an array in the DOM, when the view is navigated back to whatever new items the user added is visible through the array and hence the DOM, then when they are happy with the additions they can save it to their device.

I have tried the $ionicView.enter function on my main controller and put the $state.reload(); in the function but that still didn’t work. I did manage to get what I want as per my previous post but the loaded view gets overwritten with my previous view somehow.