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

AngularJs ngResource for nested api resurces with different endpoints

I have this endpoints /clients/:id /bills/:id /clients/:id/bills I'm trying to create some resources with angular-resource to represent my API. Clients and Bills Resources I created a resource for the clients, .factory('Clients',…
blackjid
  • 1,571
  • 16
  • 23
8
votes
2 answers

Handling data response from $resource in angular js

I have a RESTful application with Laravel 4 and Angular JS. In my Laravel Controller, public function index() { $careers = Career::paginate( $limit = 10 ); return Response::json(array( 'status' => 'success', 'message' => 'Careers…
8
votes
2 answers

Angular js way to download file and show loading screen using the $resource

I am using Angular js to show loading screen. It works for all the REST services call except REST service to download the file. I understand why it is not working because for download I am not making any service call using $resource; instead of that…
joy
  • 3,669
  • 7
  • 38
  • 73
8
votes
1 answer

nested parameters in angular query

I have a basic angular resource (angular 1.0.7): app.factory "User", [ "$resource", ($resource)-> $resource "/users/:id", { id: '@id' }, { index: { method: 'GET', isArray: false } } ] I can pass parameters like: User.index({ foo: 1,…
apneadiving
  • 114,565
  • 26
  • 219
  • 213
8
votes
1 answer

Requesting Example for angular.js $http (or $resource) POST and transformRequest as a service

Using angular 1.1.5 and needing to pass urlencoded data to the backend. I've gotten this to work with solution from here: How can I post data as form data instead of a request payload? $http({ method: 'POST', url: url, headers:…
8
votes
1 answer

Can angular resource do a bulk restful operation?

Say I have a todo application and clicking a checkbox on any individual Todo marks it as complete and does a PUT operation. Then there is a checkbox to 'mark all complete' or 'mark all incomplete'. This should mark every todo as…
Christian Schlensker
  • 21,708
  • 19
  • 73
  • 121
8
votes
3 answers

Angular Resource Encoding URL

I have a resource defined as follows: app.factory("DatumItem", function($resource) { return $resource('/data/:id', {id: '@id'}); }); In my view I have:
Test
where go() is defined in my…
Nader Hendawi
  • 375
  • 1
  • 7
  • 17
7
votes
1 answer

encodeUriSegment is not a function

Angular returns to console error encodeUriSegment is not a function it's happen when I tried call get function from angular-resource in my own controller. It's look like angular-resource can't find this one function, but it exist in angular.js…
Maciej
  • 143
  • 1
  • 2
  • 8
7
votes
1 answer

Parse JSON to Typescript class in Angular app

I'm creating a app usign angular and typescript. Everything is comming together nicely, but one issue bugs me. I define entity/model classes that i would like to pass around in the app, the data for the classes comes from JSON from $resource…
iCediCe
  • 1,672
  • 1
  • 15
  • 32
7
votes
2 answers

TypeError: value.push is not a function with Angularjs $resource query

I am returning a array of objects from the server: [{id: 1, name: "name"},{id: 2, name: "name2"}] Now I use angular-resource $query to fetch the data as it expects an array. When the data is received I get this error: TypeError: value.push is not a…
Kaspar
  • 1,600
  • 4
  • 24
  • 46
7
votes
4 answers

AngularJS $promise then() data undefined

I am trying to get data assigned to a $scope variable. Inside my $promise.then() function it is displaying correctly but outside the function it shows as undefined. The following is my controller…
7
votes
4 answers

Angular $resource does not parse correctly an integer response

I am using the Angular $resource to make requests to my controllers, implemented on a Spring application. When the controller returns just an Integer value, $resource parse it bad. Inspecting it with Firebug I get something like: Resource { 0="1",…
FrankBr
  • 886
  • 2
  • 16
  • 37
6
votes
2 answers

Why is data variable undefined in resource query transform

I am new to angular...so I am sure I am doing something wrong. Spent hours trying to search for a solution but the angularjs documentation is next to useless...and pretty much every example out there tries to set this at a global level. I am trying…
Jason
  • 2,806
  • 2
  • 28
  • 38
6
votes
2 answers

Getting ActionController::RoutingError (No route matches [OPTIONS] "/users" when trying to POST data to RAils server with AngularJS

Having issue when trying to POST data to Rails server from my AngularJS side. The server error: ActionController::RoutingError (No route matches [OPTIONS] "/users"): actionpack (4.1.9) lib/action_dispatch/middleware/debug_exceptions.rb:21:in…
6
votes
2 answers

Multiple sequential httpBackend requests cause unexpected request

I'm testing a sequence that polls a resource until a condition is met. Book = $resource("/books/:id", {id: "@id"}); function poll(success) { Book.get({id:1}, function() { if (canStop) { success(); } else { $timeout(poll,…
ChrisJ
  • 2,486
  • 21
  • 40
1 2
3
50 51