问题描述:

I have the following model:

var ThingSchema = new Schema({

name: String,

info: String,

active: Boolean,

date: Date,

hideFromUser: [String]

});

And the following method:

$scope.hideThing = function(thing) {

$http.put('/api/things/' + thing._id, {hideFromUser: [$scope.getCurrentUser().email]});

};

What I am trying to do is that for a certain thing._id, I want the current user's email address to be placed in the "hideFromUser" string array.

This works and I see the user's email get inserted into the string array, but when i refresh a page on my web app or go to a new page, the array goes back to being empty.

网友答案:

Angular is purely client side. It won't store anything (unless you put it in localStorage or sessionStorage) on the client side.

Since the array is stored client side, you'll need to ask the server(or local/session storage) for the emails that have been added on every page reload event(refresh or reload).

相关阅读:
Top