页面重新加载后angularjs中的localstorage无法正常工作

时间:2015-04-16 11:56:22

标签: angularjs angularjs-directive local-storage

您好我写下了代码,其中我从$ scope.products

中的其他控制器获取价值

我想在重新加载页面后存储此值

请帮助

app.controller("detailcntrl", function ($scope, $http, jsonService,  $location, $localStorage) {
   $scope.products = jsonService.getData();
   $scope.products = $scope.products[$scope.products.length-1];
   $localStorage.Count = $scope.products;
   console.log($localStorage.Count);
   $http.get('http://www.w3schools.com/angular/customers.php').
success(function(data, status, headers, config) {
   $scope.posts = data.records;
   $scope.posts = $scope.posts[$scope.products];
   $scope.stat = status;
   if($scope.posts == "" || $scope.posts == null){
          $('#Loading').hide();
          $('#Error').show();
   }
   else
   {
          $('#Loading, #Error').hide();
   }
   }).
error(function(data, status, headers, config) {
});
   $scope.welcomePage = function(){
          $location.path("/welcome");
   };
});

0 个答案:

没有答案