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

Prevent ngResource from requiring a returned item on $save

It seems that when I $save or use a custom $update (put or post) method on my resource that it expects the newly posted document to be returned. I don't want to return anything from my save/post ops but an ok/200/error type of statement but doing so…
cyberwombat
  • 38,105
  • 35
  • 175
  • 251
0
votes
1 answer

ngResource: Making a POST request to a specific item

I have the following basic API for a forum: POST /topics (create new topic) GET /topics (get all topics) GET /topics/1 (get topic with ID "1") And I want to add the following: POST /topics/1 (add reply to topic with ID "1") I have tried the…
callumacrae
  • 8,185
  • 8
  • 32
  • 49
0
votes
1 answer

ngResource/$resource .query() not loading data

I have built an test app very similar to the one from AngularJS' tutorial, with 1 major difference: It is initialized with Yeoman. My factory code looks like this: var deClashServices = angular.module('deClashServices',…
0
votes
0 answers

Proper way to manage resource promise when loading page

I have an html page that shows a table with a number of product rows. Each row has a select drop down that allows a user to select a "sheet". Above that table is an info box that shows the selected sheet for all products - that info varies based on…
cyberwombat
  • 38,105
  • 35
  • 175
  • 251
0
votes
1 answer

Extend angularjs $resource service to include common headers

I want to write a wrapper service to the existing angular $resource service such that some custom headers are added to the http request by default. I am aware that we can set common headers using $httpProvider.defaults.headers.common. But this way…
Vikas Gulati
  • 968
  • 2
  • 10
  • 24
0
votes
1 answer

AngularJS tokenWrapper - wrong callback arguments

AngularJS 1.2.1 ngResource 1.2.1 I got the weirdest problem. I'm using tokenWrapper by Andy Joslin (AngularJS: How to send auth token with $resource requests?) I have a resource defined like that: .factory('someService', ['$resource', 'api_host',…
Orz
  • 585
  • 1
  • 5
  • 26
0
votes
1 answer

Object # has no method 'push'

At first I had this, but got error Expected response to contain an object but got an array: angular.module('homeModule').factory("TodosFactory", ['$resource', function ($resource) { return $resource('/api/todos/:todoId', { todoId:…
Jaanus
  • 16,161
  • 49
  • 147
  • 202
0
votes
1 answer

Angular pass parameter from Template to Controller and from Controller to service

I have a code that use Resources to create and list using APIRest, I need pass a Id from template to controller and from controller to service. This is my code: Template.html
0
votes
1 answer

Add new parameter to $resource after using ngChange, Angular

I am having trouble trying to append a new url parameter after selecting a genre to create a request to the API. My ng-change is genreChange. When it been selected, it should automatically append the new url parameter like this &with_genre=fiction…
Dimitri Kouvdis
  • 121
  • 1
  • 1
  • 9
0
votes
2 answers

AngularJS ngResrouce REST Authentication

I'm trying to learn AngularJS. I'm try to make a simple authenticated get request to a REST api. At this point, i'm just trying to get a response back. I keep getting invalid key because I can't seem to send the headers properly. …
WordPress Mike
  • 448
  • 2
  • 6
  • 21
0
votes
1 answer

Custom resource method's URL not respected

I'm trying to make a list of persons. My HTTP server is able to give a JSON representation of a person on URLs like /person/[id].json, and a list of all persons at /person.infinity.json. So I have the controller, where I have defined the Person…
Vidar S. Ramdal
  • 1,164
  • 1
  • 14
  • 38
0
votes
1 answer

Angularjs $resource and json file as mock

I've got a factory like that : app.factory('AccordDepartement', function($resource, HttpCache) { return $resource('mocks/departements.json', {}, { query: { isArray: true, …
Thomas Pons
  • 7,709
  • 3
  • 37
  • 55
0
votes
1 answer

Trying to pass an object into $http request with AngularJS

I have an object, like this: $scope.user = {name: "Jim", birthday: "1/1/90", address: "123 Easy St"} I'm making an $http call to my server and I'd like to pass this user info. I'm trying like this: $http({ url: '/api/coolLookup/' + userID, …
JVG
  • 20,198
  • 47
  • 132
  • 210
0
votes
1 answer

Perform multiple requests from 1 service (angularjs)

I'm new to AngularJs and i'd like to perform several requests from my service. So far, i managed to performed one request only: My service file : ticketServices.factory('Category', ['$resource', function($resource){ var resource =…
Alexandre Nucera
  • 2,183
  • 2
  • 21
  • 34
0
votes
2 answers

AngularJS $resource save() causes HTTP Error 415 (Unsupported Media Type)

I am using Angular 1.2-RC2 (also tried 1.0.8 and 1.1.x) and the ngResource module. The backend is a Spring WebMVC application. angular.module("dox", ['ngResource']) .controller('SettingsController', function ($scope, Settings) { $scope.settings…
saw303
  • 8,051
  • 7
  • 50
  • 90