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

$resource delete function not working as expected?

I have built a simple application in Angular consuming a simple API I created myself using Laravel. The application is hosted here. The API is hosted here. Now I can log in to the application at which point the API returns a simple auth_token which…
Rohan
  • 13,308
  • 21
  • 81
  • 154
3
votes
1 answer

Share data between controllers in AngularJS

I use the following factory to fetch data from API and store it to local variable called apiData. app.factory('MyFactory', function($resource, $q) { var apiData = []; var service = {}; var resource =…
3
votes
0 answers

Get Data Object Underlying Angular $resource get() Response Object

Problem $resource does not return raw JSON object Explanation When I use the get() method on the ng $resource class, I am returned a Resource object that has the data I want, along with extras like $promise and $resolved. For instance I…
Michael Pell
  • 1,416
  • 1
  • 14
  • 17
3
votes
2 answers

How fetch the array from return of query method of a resource in AngularJS?

I have read the angularjs tutorial and now I am tryin to use in symfony application. I've implemented a rest client resource. The response json object has a sportEvents property which is an array. It is fetched. var sportServices =…
Lacces
  • 47
  • 1
  • 6
3
votes
2 answers

angularjs handling $resource $promise errors

Could somebody help me figure out how to return hard-coded data in my AngularJS factory if there is an error connecting to my API. My hard-coded data are located in another factory called "dataFactory". Appreciate the…
3
votes
4 answers

Error when accessing localhost api in chrome net::ERR_INSECURE_RESPONSE

I was trying to access api running in localhost using angular $resourses, chrome console gives me error saying ERR_INSECURE_RESPONSE. I tried disabling web security in chrome. still same error. here is the angular factory that i used. How can I…
Channa
  • 3,267
  • 7
  • 41
  • 67
3
votes
0 answers

Reject Angularjs resource promises

So I'm working on a Angularjs based mobile app. When a user taps on each of the tabs along the bottom a new route is called which is loading the partial and controller. In my controllers I often then request data from the server via Angularjs…
Ross
  • 1,425
  • 1
  • 19
  • 38
3
votes
1 answer

$resource success callback returning $promise

Using Angular 1.2.14, $resource's success callback should return an object, but it sometimes gets a $promise. The node/express web service is returning null, but Angular interprets it as a $promise. When a non-null is returned from the web service,…
Erik Olson
  • 5,807
  • 1
  • 18
  • 17
3
votes
0 answers

Error handling in an ngResource action

Is there any way to stop a transformResponse on an ngResource action from being called on a failed response. For example, the user resource here will look for data.user.firstname in the response even if the request fails and the response data…
nicholas
  • 14,184
  • 22
  • 82
  • 138
3
votes
1 answer

AngularJS CSV File Download from API

I have an admin control panel where admin users can set a few options and then click a button to run a report. The report should return a CSV file download prompt to the user. I am using ui-router and $resource services. The response headers/mime…
Harper
  • 1,285
  • 3
  • 15
  • 35
3
votes
3 answers

AngularJS $promise is undefined

I am trying to make an ajax call using $resource and load a datatable upon receiving the data from a server. But when I call a get() then I am getting $promise as undefined. I am using a factory to make the call. Here is my factory : …
SoumitraM
  • 67
  • 2
  • 8
3
votes
2 answers

Hot to return a pure array of objects from AppEngine endpoint?

I am doing AppEngine endpoints for a RESTFul backend in AppEngine. I use AngujarJS on the client side, managing server data with ngResource. My issue: I am not able to return a pure array from AppEngine Endpoint. I tried this: @ApiMethod( …
3
votes
1 answer

angular resource not invoking my error callback function

I've been at this for hours and I can't figure out why angular is not triggering my error call back when my rails back-end raises a proper error. I'm using angular 1.2.0rc1. According to the documentation: non-GET "class" actions:…
Homan
  • 25,618
  • 22
  • 70
  • 107
3
votes
1 answer

Rails4: Server error when using AngularJS resource with update method = PATCH

in Rails4 when using Angular ngResource with update method 'PATCH', I get a server error: ActionController::ParameterMissing (param not found: page): app/controllers/json_api/pages_controller.rb:39:in `filter_page_params' …
sp33c
  • 494
  • 1
  • 5
  • 15
3
votes
3 answers

AngularJS - Does $resource requests send cookies automatically?

I am using a $resource in my angularJS app. Does it send automatically my cookies? I am doing requests on the same domain.
poiuytrez
  • 21,330
  • 35
  • 113
  • 172