//app.js
var homeApp= angular.module("homeApp",['ngStorage']);
homeApp.controller("homeController",function($scope,$localStorage){
$scope.myFun=function(){
$scope.leads = document.homeForm.leads.value;
$scope.email = document.homeForm.email.value;
$scope.phone = document.homeForm.phone.value;
$scope.referance = document.homeForm.referance.value;
if ($scope.referance == "ByReferance") {
$scope.nameref = document.homeForm.nameref.value;
};
$scope.preftime = document.homeForm.preftime.value;
$scope.dataArra = [{"leads":$scope.leads , "email":$scope.email,
"phone":$scope.phone, "referance":$scope.referance,
"nameref":$scope.nameref, "preftime":$scope.preftime}];
$scope.getalb =localStorage.getItem('Leads');
if (!JSON.parse($scope.getalb)) {
localStorage.setItem('Leads', JSON.stringify($scope.dataArra));
} else {
debugger
$scope.getalb = $scope.getalb.push($scope.dataArra);
$localStorage.setItem('Leads', JSON.stringify($scope.getalb));
}
}
});
答案 0 :(得分:2)
$ scope.getalb不是一个数组。所以你不能推入它。 如果你想要$ scope.dataArra到$ scope.getalb做
$scope.getalb=$scope.dataArra