向localstorage添加值而不替换它

时间:2016-11-27 14:37:11

标签: javascript angularjs local-storage

我希望将ngStorage的值添加到locastorage addIdMatch。而在我的代码中,当我刷新页面时,它会替换已存在的值。

 $scope.addIdMatch = function(infoMatchHomeTeam, infoMatchGoalHomeTeam, infoMatchGoalAwayTeam, infoMatchAwayTeam) {
    $i = $i +1
    $localStorage[$i] = {
      infoMatchHomeTeam, infoMatchGoalHomeTeam, infoMatchGoalAwayTeam, infoMatchAwayTeam
    }
  };

0 个答案:

没有答案