Questions tagged [angular-resource]

An angularjs factory which creates a resource object that lets you interact with RESTful server-side data sources.

The returned resource object has action methods which provide high-level behaviors without the need to interact with the low level $http service.

Requires the ngResource module to be installed.

By default, trailing slashes will be stripped from the calculated URLs, which can pose problems with server backends that do not expect that behavior. This can be disabled by configuring the $resourceProvider like this:

app.config(['$resourceProvider', function($resourceProvider) {
  // Don't strip trailing slashes from calculated URLs
  $resourceProvider.defaults.stripTrailingSlashes = false;
}]);

$resource docs

756 questions
4
votes
2 answers

AngularJS: Sending requests via $resource with array type parameters (checkboxes, multiselects etc.)

I have problems trying to use the $resource library in AngularJS to send a properly serialized GET request when there is an array of checkboxes (client_status) in my GET parameters. This is the code I have right now in my controller: $scope.filters…
Thomas Cheng
  • 695
  • 12
  • 26
4
votes
2 answers

AngularJS - Using jQuery param to format resource GET verb query string

I have a backend that understands query strings in the format jQuery's $.param returns. For instance, having an object like { search: "Miller", name: ["Felipe", "Fernanda"] } Will request the URL with the following query…
kolrie
  • 12,562
  • 14
  • 64
  • 98
3
votes
1 answer

Why is my $resource POST resulting in a 404 error?

I have a .Net mobile service API that accepts an Id and a bool. If I call the API from Postman with the correct parameters and headers, it works fine. When I call it from my AngularJs app, I get a 404 error and I cannot figure out why. My backend…
Kevin
  • 4,798
  • 19
  • 73
  • 120
3
votes
1 answer

How to get boolean value using $resource of AngularJS and spring rest controller

Trying to send get boolean value from spring restcontroller using $resource service of angular js ,but getting nothing in response of $resource.get.Is there anythingextra i need to add on my client side or server side for getting boolean resource.…
Ashu Chauhan
  • 79
  • 3
  • 12
3
votes
1 answer

Angular 1.5, response status on error is always -1

I'm facing an issue when calling API, let me explain architecture first. Whole font-end application os AngularJS 1.5 based, hosted on domains like below: app1.mydomain.com, app2.mydomain.com, appN.mydomain.com I have an API (Symfony2 based - FOS…
kptLucek
  • 31
  • 7
3
votes
2 answers

ngResource does not pass parameters - how to debug?

I have the following resource definition: myservices.factory('User', ['$resource', function($resource){ return $resource('/user/:screenName', {}, { whoami: { url: '/user', method: 'GET', …
Dims
  • 47,675
  • 117
  • 331
  • 600
3
votes
1 answer

Make Synchronous call with $resource in angularjs

I am new to angularjs.After creating some projects with restful web service I got stuck at some point.So please help to me to solve that issues. I have read the difference between $resource and $http from AngularJs $resource vs $http My issue is…
Chintan
  • 59
  • 1
  • 8
3
votes
1 answer

Karma Jasmine testing $resource called from controller

I can't manage to make things work with Karma in order to test some API calls. Here is the test file : describe('Requests controller test', function() { beforeEach(module('balrogApp.requests')); var ctrl, scope; var requestData = [ {id:…
Ellone
  • 3,644
  • 12
  • 40
  • 72
3
votes
1 answer

Does angulars $resource support etags?

I'm seeing contradicting answers https://stackoverflow.com/a/25004605/4642530 and https://stackoverflow.com/a/29067231 and the docs don't mention if they support it or how to handle etag if not. Anyone know?
garrettmac
  • 8,417
  • 3
  • 41
  • 60
3
votes
0 answers

How to handle empty string query parameters in angularjs?

I have a query on my $resource like so: userResource.query( { lastName: vm.lastName, pageSize: vm.pagingData.pageSize, pageNumber: vm.pagingData.pageNumber }, function(data) { vm.totalItems =…
BBauer42
  • 3,549
  • 10
  • 44
  • 81
3
votes
3 answers

Angular reload resource that is being watched

I think this seems like an obvious question, but my brain seems to be a bit fried. I have a resource Book = $resource("/books/:id", {id: "@id"}); book = Book.get(1); I want to refresh the object to get changes from the server. I know I can do that…
ChrisJ
  • 2,486
  • 21
  • 40
3
votes
2 answers

Reading data from $resource.get() in AngularJS

JSON/XML from REST { litm: "T00000245", lotn: "00004" } T00000245 00004 AngularJS controller //Searching a product with serial number/LOTN $scope.searchProduct = function () { var…
Sami
  • 2,311
  • 13
  • 46
  • 80
3
votes
2 answers

How to access raw JSON string of ngResource response?

I use ngResource to query a JSON service and per default Angular parses the response. Unfortunately I'd also like to have access to the raw response string. Here is a snippet of what I'd like to achieve: var app = angular.module('plunker',…
hupf
  • 604
  • 1
  • 6
  • 10
3
votes
1 answer

How to loop through $resource returned query and get desired value?

I am using MEANJS In my controller i have // Find a list of Cars $scope.findHome = function() { $scope.cars = Cars.query(); console.log($scope.cars); }; Which outputs here i want to get the _id string inside the first array 0:…
Hareesh
  • 6,770
  • 4
  • 33
  • 60
3
votes
1 answer

How to integrate resource with two different services to query server with params provided by them?

I'm learning Angular and I don't like my current approach. The current controller uses first Geolocation service and when getLocation() is resolved, then the Pagination service is invoked with the location param. Is there any better solution to…
luzny
  • 2,380
  • 7
  • 30
  • 64