After linking to Link , I am trying to get JSON data in my angular service.
Services:
.factory('restservice', ['$rootScope','$http', '$q', '$log', function($rootScope,$q, $http) { return { getData: function() { var defer = $q.defer(); $http.get('xyz.com/abc.php', { cache: 'true'}) .success(function(data) { defer.resolve(data); }); return defer.promise; } }; }])
Controller:
.controller('RestaurantsCtrl', function ($scope,$http, restservice,restViewservice){ restservice.getData().then(function(data) { $scope.Restaurants = data; }); })
After implementing this console, it says ' $ q.defer is not a function .
What is the problem here? Please help ... !! I am new to angular Js, so sorry if something is wrong.
source share