List not refreshing in my angular site

I use Ionic and AngularJS and have the following problem:

Here is the view:

<ion-list>
    <ion-item ng-repeat="item in items track by $index" >
        <h1>{{item.text}}</h1>
        {{item.timestring}}
    </ion-item>
</ion-list>

and the controller:

$scope.items = foo.getItems();

the method in foo looks like:

foo.loclStorages = JSON.parse(localStorage.getItem("foo"));
foo.getItems = function () {        
    if (foo.loclStorages === null) {
        return [];
    } else {
        return jsdata.loclStorages.items;
    }
};

Now the problem: When the list is empty and I add the first element, then I first need to update the site to see it. When I already have items in the list, i can see it instantly after the update.

What I need to do to also see it instant after adding the first element?

When your list is empty, then $scope.items equals some empty array []. When your list isn't empty, then $scope.items is a reference to jsdata.loclStorages.items.

Since these two arrays aren't the same reference, then when your list starts as empty, adding items to localStorages.items will have no effect on the array in $scope.items.

To solve this, you need to check when you add an item if the reference in the scope is the same reference as the array in jsdata. If not, make sure to call $scope.items = foo.getItems(); again.