Vote count:
0
var app = angular.module("myApp", []);
app.factory('getDB', function($http, $rootScope, cacheDB) {
return {
category : function (callback) {
$http.get('url').then( function (response) {
$rootScope.categoryDB = response.data;
cacheDB.put('category', response.data;);
callback(response.data);
});
}
}
});
app.factory('cacheDB', function($cacheFactory) {
return $cacheFactory('cacheData', {
capacity: 1000
});
});
app.controller('mainCtrl', function ($scope, $rootScope, cacheDB, getDB){
console.log('get : ', cacheDB.get('category'));
var category = $rootScope.categoryDB;
console.log('getDB : ', category);
});
i cant get any data from factory, how can i get $http(url mysql data) from factory or service thanks.
asked 3 mins ago
angularjs cacheFactory not work in $http
Aucun commentaire:
Enregistrer un commentaire