I have to get the data which comes from API and in this case I used a controller and a service, it's service `daryo.factory('daryoSvc', ['$http', function ($http) {
var categories = [];
var categoriesjon = function () {
$http.get('http://localhost:18737/Category/GetCategories').
success(function (data, status, headers, config) {
categories = {
"one": "two",
"key": "value"
};
alert('g');
})
.error(function (data, status, headers, config) {
console.error(data);
});
return categories;
}
var factoryService = {
categories: categoriesjon
};
return factoryService;
}]);`
and here is my Controller function `daryo.controller('daryoCtrl', ['$scope', 'daryoSvc', function ($scope, daryoSvc) {
var self = $scope;
self.categories = daryoSvc.categories;
console.log(daryoSvc.categories);
}]);`
It's not working correctly,because I didn't use $q promise options and I didn't find a good solving for that, How can I fix that? Thanks!