Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将数据存储到$localStorage。$angularjs中的默认值_Php_Angularjs - Fatal编程技术网

Php 将数据存储到$localStorage。$angularjs中的默认值

Php 将数据存储到$localStorage。$angularjs中的默认值,php,angularjs,Php,Angularjs,我正在尝试将数据存储在$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); /*

我正在尝试将数据存储在$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
           }]
new_布局:[{
_身份证号码:13952057,
名称:“默认值1”,
第页:[{
页码:1,
产品:[名称:'李'}]
}],
图像:“”,
宽度:25
}]
[{
_身份证号码:55531173,
名称:“默认值2”,
第页:[{
页码:2,
产品:[名称:'Jo'}]
}],
图像:“”,
宽度:25
}]

对于本地存储,有一个模块可以查看以下url:

以及HTML5本地存储和angularJs的其他链接

此外,您还可以使用ngstorage:

ngStorage包含两项服务:$localStorage和$sessionStorage

angular.module('app', [
   'ngStorage'
]).controller('Ctrl', function(
    $scope,
    $localStorage,
    $sessionStorage
){});
你可以看到
. 希望这能有所帮助。

对于本地存储,有一个模块可以查看以下url:

以及HTML5本地存储和angularJs的其他链接

此外,您还可以使用ngstorage:

ngStorage包含两项服务:$localStorage和$sessionStorage

angular.module('app', [
   'ngStorage'
]).controller('Ctrl', function(
    $scope,
    $localStorage,
    $sessionStorage
){});
你可以看到
. 希望这有帮助。

为什么不以JSON格式将数据从服务器传输到客户端,在客户端上使用
localStorage.setItem('new_layout',JSON.stringify(data))
呢?为什么不以JSON格式将数据从服务器传输到客户端,在客户端上使用
localStorage.setItem('new_layout',JSON.stringify(data))