我试着按照这里的例子,我知道可能有几种不同的方法可以将对象添加到 $localstorage 中的数组而不覆盖它,但我至少找不到其中一个。
**
类型错误:$scope.sTempLoc.push 不是函数
**
.controller('AddWfhCtrl', function($scope, $http, $rootScope, $localStorage, $ionicLoading, $ionicHistory, $cordovaGeolocation,$ionicPopup, focus){
$scope.saveWfhLocation = function (){
$scope.sTempLoc = [];
if(typeof $scope.uCurLocDtls.uCuWfhLocName != "undefined" || $scope.uCurLocDtls.uCuWfhLocName != ""){
if(angular.isDefined($localStorage.userWFHLocs)){
$scope.sTempLoc = $localStorage.userWFHLocs;
$scope.sTempLoc.push($scope.uCurLocDtls);
$localStorage.userWFHLocs = $scope.sTempLoc;
}else{
$localStorage.userWFHLocs = $scope.uCurLocDtls;
}
$ionicHistory.goBack();
}
}
})