angular.module('adminApp')
.service('subCategoryFinder', ['$http',function($http){
var self = this;
self.getSubCategory = function(){
var data = {};
$http.get('/app/admin/category/category.json').then(function (response) {
data = response.data;
console.log(data);
});
return data;
}
}]);
I'm trying to update the data variable inside getSubCategory function but the data variable updates only inside inner functions scope and fails to update the outer function's data variable resulting in empty object i.e. {} as initialized. Thanks in advance!