我现在正在使用浏览器的本地存储构建一个客户收银员类型的应用程序。我想出了如何使用本地存储,但如果我从客户方发出新订单,它不会更新收银台。
app.controller('posController', function($scope,localStorageService,Data,$rootScope,$window){
console.log(localStorageService.get("placedOrder"));
$scope.orders = localStorageService.get("placedOrder");
});
app.controller("orderController",function($scope,Data,localStorageService){
var arr = localStorageService.get("placedOrder") || [];
arr.push({"name":$scope.name,
"order": $scope.order,
"time": Data.time,
"email": Data.email
});
localStorageService.get("placedOrder",arr)
console.log(Data.placedOrder);
});
所以 posController 应该在 ordercontroller 更新 localStorage 后立即更新。