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
2
votes
1 answer

Angular and Karma testing a service that uses $resource and returns a promise

I am trying to develop a Unit Test using Jasmine for my AngularJS User service that relies on $resource. My test which is: 'use strict'; describe("User Service Test", function() { var service; var mockLoginUser = { email: 'hidden', password:…
2
votes
2 answers

Using $resource in a promise chain (fixing deferred anti-pattern)

I have a service with a method that gets me a list of project types using a $resource. It's working well for me, except that if I make multiple nearly simultaneous calls (from say, two directives) each will create another request instead of using…
coblr
  • 3,008
  • 3
  • 23
  • 31
2
votes
2 answers

How to wrap an object around my data when using Angular $resource

I have a simple angular service that returns a $resource. Lets say it looks like this: $resource '/users/:id/:options.json', {id: '@id', options: '@options'}, create_user: { method: 'POST' } Now in my…
Kaspar
  • 1,600
  • 4
  • 24
  • 46
2
votes
2 answers

Can't get array by $resource

Can't get array by $resource. Can you help me? When I use $http all is well I have error in console: TypeError: undefined is not a function at http://127.0.0.1:9000/bower_components/angular-resource/angular-resource.js:597:29 at forEach…
2
votes
2 answers

Angular JS Sending Array data with $resource to .NET API

Yes, I know there is a gazillion posts about sending array data using angular $esource. I read this, this, and pretty much the top 10 google results on this topic, but I still can't make it work. I suspect that it might have to do with the server…
Tina Chen
  • 939
  • 1
  • 7
  • 14
2
votes
0 answers

Using Angular Client with WebAPI and CORS

I've a problem for sending data to the server via POST/DELETE. I always get a CORS error when I'm trying to send data to the WebAPI. The client-side was implemented with AngularJS and the server-side with ASP.NET WebAPI by C#. Here's the Code of…
yuro
  • 2,189
  • 6
  • 40
  • 76
2
votes
1 answer

Angular : intercept specific request with $resource

I'm new to Angular, and am working on an interceptor. I created an angular factory to get some data from an API like that : app.factory('Connection',['$resource',function($resource) { return $resource('url',{param1: '1',param2: '55'},); }]); I…
Arhyaa
  • 369
  • 1
  • 3
  • 21
2
votes
2 answers

Why are my requests to web.api being blocked by long running controller code?

I'm working on my local development environment using angular to issue ajax calls to Web.API (IIS 8.5 hosted). I'm making 5 calls via different angular controllers simultaneously, each of which look like this: $scope.medications =…
sonicblis
  • 2,926
  • 7
  • 30
  • 48
2
votes
2 answers

Saving subresource with Angular's $resource

I have a factory defined which returns a $resource: myApp.factory('Region', function($resource) { return $resource(baseUrl + '/templates/:templateId/regions/:regionId', null, { query: { method: 'GET', isArray:…
John Dorean
  • 3,744
  • 9
  • 51
  • 82
2
votes
4 answers

Doing a GET passing a complex object with angular

I am using AngularJs and Resources module. I want to do a GET to obtain an object.. to do this GET I do not have to pass simply the ID to the server, but I should pass a complex object with different properties and values.. Here the code I am…
Simone
  • 2,304
  • 6
  • 30
  • 79
2
votes
1 answer

Testing AngularJS resource with Jasmine

I would like to test my resource with following URL: $resource(API_URL+'items/:id', {}); Where API_URL equals /app/api/ describe('item',function(){ it('should return same item id',function(){ …
2
votes
1 answer

Spring MVC and AngularJS @RequestMapping

I have built an application with Spring-boot and AngularJS with the REST End Point application. I got a little stuck with @RequesMapping in Spring Controller I've made. The problem is, I have the example…
2
votes
1 answer

REST API Endpoint for Retrieving Empty Object

I have a REST API endpoint for creating an empty object. What is the "standard" url scheme for this GET method? I'm currently using a factory in an angularjs app to make the call to the server. Right now I have the following scheme: GET…
miniscem
  • 327
  • 1
  • 5
  • 14
2
votes
1 answer

Handling "If-None-Match" header with angular resouce?

I have an angular app which talks to my rails api via ng resource. In my response I set etag in my header which I get in my response headers but while making the same query again If-None-Match header is not set and in turn my caching doesn't works…
ptwo
  • 461
  • 4
  • 13
2
votes
2 answers

Retrieving parent plus related children in one Parse REST API call

I'm building out a little app and the first thing I need to do is make a call to Parse's REST API using AngularJS's ngResource. I've successfully constructed two Parse classes (let's call them "Parent" and "Child" for now) and set up a many-to-many…
slashwhatever
  • 732
  • 8
  • 24