2014-12-01 68 views
0

此代码有效;该getData()函数被调用:在模块中包含Angular localStorageService会导致本机错误

var app = angular.module('POC', []); 
    app.controller('POCCtrl', ['$scope','$timeout', function ($scope, $timeout) { 

     <snip> 

     $timeout(function() { 
      $scope.getData() 
     }, 250, $scope); 

    ]); 

但下面的代码,它引用localStorageService,导致IE本地错误,当我尝试运行和调试页面。从不调用getData()函数。我错过了什么?本地存储服务是否也必须包含在模块中?

 var app = angular.module('POC', []); 
     app.controller('POCCtrl', ['$scope','$timeout', 'localStorageService', 
      function ($scope, $timeout, localStorageService) { 

      $timeout(function() { 
       $scope.getData() 
      }, 250, $scope); 

     ]); 

回答

0

使用

app.controller('POCCtrl', 
     function ($scope, $timeout, localStorageService) { 

); 

我不知道为什么,但控制器只是不采取localStorageService您正在使用的方式,今天我同样的错误。看到我的问题(我自己也在寻找解释)

Error in angular-js while using angular-local-storage

相关问题