Javascript 角度$http.put条目在页面刷新时消失
我有以下型号:Javascript 角度$http.put条目在页面刷新时消失,javascript,angularjs,mongoose,Javascript,Angularjs,Mongoose,我有以下型号: var ThingSchema = new Schema({ name: String, info: String, active: Boolean, date: Date, hideFromUser: [String] }); 以及以下方法: $scope.hideThing = function(thing) { $http.put('/api/things/' + thing._id, {hideFromUser: [$scope.getCurre
var ThingSchema = new Schema({
name: String,
info: String,
active: Boolean,
date: Date,
hideFromUser: [String]
});
以及以下方法:
$scope.hideThing = function(thing) {
$http.put('/api/things/' + thing._id, {hideFromUser: [$scope.getCurrentUser().email]});
};
我想做的是,对于某件事,我希望将当前用户的电子邮件地址放在“hideFromUser”字符串数组中
这是可行的,我看到用户的电子邮件被插入到字符串数组中,但当我刷新web应用程序上的页面或转到新页面时,数组返回为空 Angular纯粹是客户端。它不会在客户端存储任何东西(除非您将其放在localStorage或sessionStorage中) 由于阵列存储在客户端,因此需要向服务器(或本地/会话存储)请求在每个页面重新加载事件(刷新或重新加载)中添加的电子邮件