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
2 answers

AngularJS: Issue with interceptors in $resource

Im having a weird behavior manipulating a response through $resource with a custom interceptor. If I use a response interceptor like this : angular.module( 'app.services', [] ) .factory( 'Product', function( $resource, routesConfig ) { …
avcajaraville
  • 9,041
  • 2
  • 28
  • 37
2
votes
1 answer

Extract data from $resource.get(...).$promise

I use $resource to get data from Facebook's Graph api: resource = $resource( "https://graph.facebook.com/v2.2/:api/:id/:node/" ) So for instance, I made a successful request to 'https://graph.facebook.com/v2.2/user.id/albums/'…
Lelouch
  • 2,111
  • 2
  • 23
  • 33
2
votes
0 answers

MEAN add an object that utilize two existing models

Hi I am experimenting with MEANjs for development. I have made an app that consist of CRUD for "Accounts", "Incomes" and "Expenses". Each of which are created using yo meanjs:crud-module . Now I wont to expand my project with a type:…
David Karlsson
  • 9,396
  • 9
  • 58
  • 103
2
votes
1 answer

using http cache in angularjs-rails-resource

I'm using the angularjs-rails-resource project to wrap my http rest services. One thing I didn't find in documentation is regarding cache, some of my methods should access the server only once and cache their response. Is there an easy way to…
Chen Kinnrot
  • 20,609
  • 17
  • 79
  • 141
2
votes
2 answers

How do I send multiple headers with angularJS resource?

Trying to send multiple headers in the same request with angularJS this is what I have... var auth = $resource("", {}, { GetUserDetails: { url: Config.api.user.details(), method: 'POST', …
Exitos
  • 29,230
  • 38
  • 123
  • 178
2
votes
4 answers

Angular $resource - How can I use promise?

How can I use promise with $resource? This is my service, app.service("friendService",function( $resource, $q ) { // Return public API. return({ addFriend: addFriend, updateFriend: updateFriend, …
Run
  • 54,938
  • 169
  • 450
  • 748
2
votes
1 answer

Rails 4 add unexpected param in AngularJS resource post

When doing a ng-resource post to my Rails 4 app, rails is not adding the correct params, indeed it is adding an unexpected param called 'base' in the post. My service: App.factory('Rule', ['$resource', function ($resource){ return…
felipeclopes
  • 4,010
  • 2
  • 25
  • 35
2
votes
0 answers

Clever bulk update in Angular $resource

Here's what I'd like to achieve: Say you have a todo list and do the following changes: Mark as complete task 1 Change the name of task 2 Mark as complete task 2 Change the name of task 1 At present, my system can achieve this by firing 4 http…
gkpo
  • 2,623
  • 2
  • 28
  • 47
2
votes
1 answer

AngularJS - cancel previous $resource $promises if there is a new request

I have a form with 2 fields: username and password. When my username model changes, I make a request to an API to perform some checks. When I make x calls separated by t milliseconds to a $resource factory, I would like to know if : in my…
Niflhel
  • 663
  • 1
  • 5
  • 19
2
votes
1 answer

Why can't I access the data within a with .query() returned $resource object?

I am trying to access the data in an object that is returned using $resource. I thought it would be similar to accessing data inside an object by using a dot but this doesn't work. In the console I can see the object contains an array named "jobs"…
Chantal
  • 959
  • 2
  • 12
  • 24
2
votes
1 answer

AngularJS weird behaviour with $resource and $httpBackend

I have following AngularJS resource exposed as a service myServices.factory('Service1', ['$resource', function ($resource) { var Registrations = $resource('/api/v1/registration/:id'); return { getForTcn:…
KlsLondon
  • 1,160
  • 1
  • 9
  • 18
2
votes
1 answer

How can I synchronize two $resource calls in AngularJS

I am trying to do something like the following: In my controller I have functions that use $recource call to get data from database. The service 'myService' var fillSubData = function (containerToFill) { resService.getSubDataFromDB(//$resource…
Adrian Espinoza
  • 73
  • 2
  • 10
2
votes
1 answer

Cannot read response from AngularJS $resource DELETE

I am trying to use AngularJS $resource to DELETE data from my server. However, when I write the result to console, I do not see the data. However, when I go to "Network" in Chrome's console, I see the DELETE in the Name Path left column. When I…
Randall Flagg
  • 4,834
  • 9
  • 33
  • 45
2
votes
1 answer

how to fix $resource:badcfg in my case?

Here is my js code var MYModule = angular.module('myApp', ['ngRoute', 'myAppServices']) .directive('loading', ['$http', loadingDirective]) .config(myRouter); angular.module('myAppServices', ['ngResource']) .factory('Users',…
coure2011
  • 40,286
  • 83
  • 216
  • 349
2
votes
2 answers

Getting string array using angular $resource TypeScript

by making request to WebAPI I expect to receive string array with several values (units of measurement in this case) ["KGM", "MTR"] Unfortunately in response I'm receiving array of resources and within array of chars [0] Resource [0]: "K" …