Why screen reloads each time i visit it?


E.g. i use default ionic app “tabs”.
So for the “home” tab i have this code in the controller:

.controller('DashCtrl', function($scope) {
    $scope.news = "Loading...";
		$scope.news = data;

html code looks like this:

<ion-view title="Dashboard">
  <ion-content class="padding">

So when I’m visiting “home” tab after little amount of time I see result of $http request.
Then I’m going to the “Account” tab.
And then I’m going back to “home” tab again.
But I’m don’t see news that was loaded few moments ago !
I see text “Loading…” and again after few seconds news loads again.

How can i prevent this ?


You aren’t caching the data that you return from the HTTP get request, so each time you reload the Dashboard you are re-GETing the data.

Look into Angular’s $cacheFactory


Oh Thank You !
But if i have this code on the page:

    <p ng-click="foo()">{{text}}</p>


$scope.text = 'hello';
	$scope.foo = function () {
		$scope.text+= ' world !';

If i click on ‘hello’ it becomes ‘hello world’, but if I go to another tab and return to this one - I’ll see only ‘hello’ without ‘world’.
What should I do in this case ?