小编Ani*_*hta的帖子

如何使用angularjs在本地存储中保存json响应?

我有api返回json响应,我想在localstorage中存储json响应,以便在我使用angularjs的另一个html页面中使用该响应.

这是我的代码返回json响应....

QAApp.controller('SearchCtrl', function ($scope, $http, $location) {

  $scope.search = function (searchtag) {
           var request = $http({
                          method: 'GET', 
                          url: server + 'api/question/tagged/' + searchtag,
                        });
                request.success(function(data, status, headers, config) {
                console.log(data);
                $scope.qa = data;
            });

        }
  }); 
Run Code Online (Sandbox Code Playgroud)

请告诉我如何存储它...

json angularjs

14
推荐指数
2
解决办法
3万
查看次数

标签 统计

angularjs ×1

json ×1