Using ngStorage as an array in ionic
trying to convert this
.service('dataStore', function($localStorage,$scope){
this.entfeeds=[];
this.topfeeds=[];
this.intfeeds=[];
})
.controller('GenFeedCtrl', function ($scope,....
$scope.feeds = FeedList.get(feedSources, dataStore.topfeeds);
which works except when executed on cordova phone it only returns two items
so i am trying to use ngStorage to store the array
.service('dataStore', function($localStorage,$scope){
$scope.$storage = $localStorage.$default({
etf:[],
tpf:[],
itf:[]
});
this.entfeeds=$storage.etf;
this.topfeeds=$storage.tpf;
this.intfeeds=$storage.itf;})
.controller('GenFeedCtrl', function ($scope,....
$scope.feeds = FeedList.get(feedSources, dataStore.topfeeds);
but not working in emu browser, following error appears
Error: [$injector:unpr] Unknown provider: $scopeProvider <- $scope <- dataStore
http://errors.angularjs.org/1.3.13/ $ injector / unpr? p0 = copeProvider% 20% 3C-% 20% 24scope% 20% 3C-% dataStore at http: // localhost: 8100 / lib / ionic / js / ionic.bundle.js: 8762: 12
source to share
The service is not $scope
. $scope
is only required to view related components and the service has nothing to do with the view.
$rootScope
can be entered into a service, but is not suitable for storing data. This will be used more often in the event broadcast service
You can use variables, but to define what you don't directly need to bind to this
.service('dataStore', function($localStorage){
var $storage = $localStorage.$default({
etf:[],
tpf:[],
itf:[]
});
this.entfeeds=$storage.etf;
this.topfeeds=$storage.tpf;
this.intfeeds=$storage.itf;
})
source to share