我正在尝试将数据存储在$ localStorage中请帮助我 下面是我在angularjs中的代码
$http.get(token_url+"jewellery/quick_keys/get_layout_data/"+edit_layout_id).success(function(result){ /* token url is to provide path to get layout list as per id*/
console.log(result); /*result is in the form of jeson encode*/
});
在控制台中,我将数据作为
new_layout [Object { _id=13952057, name="Default 1", page=[5], more...}, Object { _id=55531173, name="Default 2", page=[3], more...}, Object { _id=53907588, name="Default 3", page=[3], more...}, Object { _id=6117442, name="Default 4", page=[3], more...}]
我想将此数据存储到$ localstorage。$ default,格式为
new_layout: [{
_id : 13952057,
name: 'Default 1',
page: [{
pageID : 1,
product : [ name: 'Lee' }]
}],
image: '<img src = "'+token_url+'images/grp1_setting_icon.png" >',
Width: 25
}]
[{
_id : 55531173,
name: 'Default 2',
page: [{
pageID : 2,
product : [ name: 'Jo' }]
}],
image: '<img src = "'+token_url+'images/grp1_setting_icon.png" >',
Width: 25
}]
答案 0 :(得分:0)
对于本地存储,有一个模块可以查看以下网址:
https://github.com/grevory/angular-local-storage
以及HTML5本地存储和angularJs的其他链接
http://amitavroy.com/justread/content/articles/html5-local-storage-angular-js
此外,您可以使用ngstorage:
ngStorage包含两项服务:$ localStorage和$ sessionStorage。
angular.module('app', [
'ngStorage'
]).controller('Ctrl', function(
$scope,
$localStorage,
$sessionStorage
){});
你可以看到demo 。希望这会有所帮助。