Cannot read property 'splice' of undefined

I'm trying to remove the item from the localstorage json data. but have error in my console 'splice' undefined. Please Help Me..

This is my Controller

app.controller('favgame', function($scope, $localStorage){
    $scope.saved = localStorage.getItem('favgame');
    var favgames = JSON.parse($scope.saved);
    $scope.onItemDelete = function(index) {
      $scope.favgames.splice(favgames[index],1);
    };
});

This is my ng-click code

<ion-delete-button class="button button-clear ion-minus-circled" ng-click="onItemDelete($index)">
</ion-delete-button>

Thank You!

Incorrect splice, instead use below. $scope.favgames, doesn't contain any values and is undefined.

favgames.splice(index,1);

Or set,

$scope.favgames = favgames.splice(index,1);

you have to change this line:

var favgames = JSON.parse($scope.saved);

with this one:

$scope.favgames = JSON.parse($scope.saved);

Please change var favgames to var $scope.favgames