当我向购物车添加商品并登录时,购物车中的商品被删除。所以我想将访客的购物车商品移动到登录用户的购物篮中。 我正在使用angularjs,我正在考虑使用$ window.localStorage()
情形:
这是我的功能
Auth.$onAuthStateChanged(function (currentUser) {
if(currentUser) {
firebase.database().ref('users/' +
currentUser.uid).once('value').then(function (loggedUser) {
$scope.$apply(function () {
$scope.user_type = loggedUser.val().user_type;
});
});
}
});
$scope.$on('getAuth', function () {
DashboardService.getOrders().then(function (orders) {
model.length = orders.length;
$scope.$apply()
});
});
$scope.$on('OrdersUpdate', function (event, args) {
model.length = DashboardService.allOrders.length;
});
function signOut() {
DashboardService.allOrders = [];
// $state.go('home-page');
Auth.$signOut();
$window.localStorage.clear();
$location.path('/');
}