Answer the question
In order to leave comments, you need to log in
How to save query result when using $resource?
Why when using code like:
$http.get(url).
success(function(response) {
$scope.receiveData = response;
});
var someServices = angular.module('someServices', ['ngResource']);
someServices.factory('QueryesService', ['$resource', function($resource) {
return $resource('http://url/:currentService/:param');
}]);
var someControllers = angular.module('someControllers', []);
someControllers.controller('someCtrl', ['$scope', '$http', 'QueryesService', function($scope, $http, QueryesService) {
$scope.getSomeData = function() {
QueryesService.get({currentService : 'service1'}, function(response) {
$scope.receiveData = response;
});
};
$scope.receiveData; //undefined
}]);
Answer the question
In order to leave comments, you need to log in
Maybe
.controller 'someCtrl', ($scope, QueryesService) ->
$scope.receiveData = {}
$scope.getSomeData = ->
QueryesService.get currentService : 'service1', (response) ->
angular.extend $scope.receiveData, response
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question