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

AngularJS Promise retries

I am having some trouble getting a retry function to work and was hoping for some assistance. I have a $resource that I want to have called until a success condition occurs or the maximum retries has been exceeded. The issue I seem to be running…
Brian
  • 2,294
  • 6
  • 30
  • 51
6
votes
3 answers

How to configure Angular $resource (ngResource) to pull data from another domain using CORS

I'd like to be able to setup resources using $resource using CORS to request my data. I've got CORS working with $http but the same techniques don't apply to $resource and I was hoping someone can come to my rescue and show me how with…
5
votes
3 answers

ng-Table sorting and searching not working when use $resource

i started with an existing example of ngTable an modified it a bit to use ngResource. using resource factory it populates the data but searching and sorting doesn't works. http://codepen.io/anon/pen/yVGKMZ Created a pen above. var app =…
Raas Masood
  • 1,475
  • 3
  • 23
  • 61
5
votes
1 answer

How do I implement the C in CRUD with AngularJS, components, and ngResource?

I'm quite new to Angular, and I'm adapting a simple CRUD app written using standard controllers and ngResource to use the components introduced in 1.5. None of the docs and resources I've found so far discuss how to: create a new item from…
5
votes
2 answers

PUT request sending params via URL

I have a order resource that looks like so. .factory('Order', order) order.$inject = ['$resource', "ApiEndpoint"]; function order($resource, ApiEndpoint) { return $resource(ApiEndpoint.url + 'orders.json', {}, { create: {method: 'POST', url:…
thank_you
  • 11,001
  • 19
  • 101
  • 185
5
votes
1 answer

Angular-poller doesn't work on IE11 when the development tool is not opened

I am working on an angular v1.3 app and I am using angular-poller in one my controllers to automatically send request to get new data from my backend every 2 seconds. It works fine in Chrome, but does not work in IE11. But strangely enough, I am…
5
votes
0 answers

Resource + Socket.io factory in Angular.JS

I'm writing a web application using Angular.JS, which uses a backend system written in Express and Socket.IO (a Node module). I've written a factory in Angular.JS for listing Elements: angular.module('myApp.api', ['ngResource']) …
Flock Dawson
  • 1,842
  • 4
  • 22
  • 34
5
votes
1 answer

How to get the complete response headers from angular resource

I'm sending a request with an Angular $resource: myResource.get({ foo: bar }, function success(data, headers) { console.log("data:", data); // Prints data console.log("headers:", headers()); // Prints only few headers …
tezqa
  • 139
  • 8
5
votes
1 answer

Sending ETag with $resource

Using Angular JS's $resource service, is there a way to specify the If-None-Match and ETag headers for the 2nd, 3rd, etc polls of a resource? var SummarySearch = $resource(<>, { }, { get: { …
Trey Mack
  • 4,215
  • 2
  • 25
  • 31
5
votes
2 answers

Make angularjs $resource return array of [OO] objects

How to make angularjs $resource return an array of objects derived/prototyped from specified domain object? Here is an example on http://plnkr.co/edit/AVLQItPIfoLwsgDzoBdK?p=preview that processes a set of Notes objects. app.controller('MainCtrl',…
okigan
  • 1,559
  • 2
  • 18
  • 33
5
votes
1 answer

AngularJS CORS don't send all cookies with credential, but jQuery send

I'm using AngularJS v1.2.16 in my frontend. I've created a simple service: app.provider('Site', function () { var apiServer = 'http://api.example.com'; this.$get = ['$resource', function ($resource) { var site = $resource(apiServer +…
J Sorel
  • 343
  • 2
  • 18
5
votes
1 answer

How do I set a conditional $resource timeout in angularjs?

It seems pretty clear how to set a global method to abort http requests. Something along the lines of $scope.canceller = $q.defer(); var API = $resource('http:/foo.com', {}, {get: { method:'GET', …
Greg Michalec
  • 849
  • 3
  • 10
  • 17
5
votes
1 answer

Items disappear when saved

I created a directive to display data. I can include it in an ng-repeat and see that the model is connected. When I click away and return the page, the data is displayed again with previously made changes. I used ngResources to load the data from an…
5
votes
1 answer

Initializing an angular resource object instance without calling the server

In Backbone.js, one can instantiate a model with pre-existing JSON data by using var user = new Backbone.Model({ name: "John Doe", age: 30 }); And then perform updates with a single call user.save({ age: 31 }, { success: successCallback, error:…
sa125
  • 28,121
  • 38
  • 111
  • 153
4
votes
3 answers

Error status codes are not being caught

I am trying to catch angular resource's HTTP error status code (!=200). My Service, where I have resources defined: (apiService.js) .factory('ApiService', function($resource, $http, localStorageService, CONFIG) { var base_api_url = api_url =…
dease
  • 2,975
  • 13
  • 39
  • 75