我可以使用一些帮助来了解如何将数组存储到会话存储中:
所以我有一个返回此
的json对象Object
Objectauthority: "USER_ROLE"
email: "1@1"
enabled: true
firstName: "1"
id: 1
lastName: "1"
password: "$2a$10$qPjtVDxkCh3KaE2mr0.ZeuyyjceLy7JPVmelttVf7uekSQq01fZ9u"
but it has also returns a client list
clientList: Array[7]
city: "Brussel"
company: "John Doe's coffee shop"
country: "Belgium"
...
这是angularjs代码
$http.get('/api/getuser').success(function(data) {
$scope.userdata = data;
console.log(data)
//Here we add all the stuff we need to the sessionStorage
$sessionStorage.userid = data.id;
$sessionStorage.userEmail = data.email;
$sessionStorage.sampleString = "This is a sample string";
//But how can i store the array to the sessionStorage ?
//Is something like this possible ?
$sessionStorage.clientArray[] = data.clientList[]
})
答案 0 :(得分:0)
好的,我有它工作我只需要删除[]所以这样的工作:
$sessionStorage.clientArray = data.clientList