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
1
vote
1 answer

How can I make an AngularJS $resource to return the same instance when referenced from multiple controllers?

I have multiple directives combined in the same view, all accessing the same Angular $resource. One of the directives contains a form. I would expect $resource to return a singleton so any change in the data would be reflected automatically in all…
Miki
  • 1,625
  • 21
  • 29
1
vote
1 answer

OverWriting URL using angular resource not working

I am using angular resource in order to retrieve a record from my AP. Below is my relevant controller information. $scope.formInformation = formService.get({id:$state.params.form_id }); Below is my service (function(){ "use…
1
vote
1 answer

external resources using typescript variable

I have the external link to the css file stored as string variable in typescript component. I want to use in a link tag in html to import the external css file for my web theme. I have defined the link variable as below.…
saikat
  • 145
  • 1
  • 14
1
vote
1 answer

What does AngularJS $resource.delete() return?

I am using AngularJS $resource to list, create, and update resources and it works fine. For example: getFoo = (fooId) => { const Foo = $resource("api/foos/:fooId); return Foo.get({fooId}); }; This returns a Foo instance that has a Foo.$promise…
Garret Wilson
  • 18,219
  • 30
  • 144
  • 272
1
vote
1 answer

How make $resource wait more timeout than 30s?

Conbsider the code: var searchResource = function(token) { var _url = ['my_url', '/somePAth'].join(''); return $resource(_url, {}, { query: { timeout: 300000, method: 'GET', headers: { …
Cherry
  • 31,309
  • 66
  • 224
  • 364
1
vote
1 answer

Angularjs $resource save action return promise object instead actual value of response

I defined this factory to call rest methods: (function() { 'use strict'; angular.module('rgh').factory('Charge', Charge); function Charge($resource) { return $resource('rgh/charge/charge', {}, { 'save' : { …
Rasool Ghafari
  • 4,128
  • 7
  • 44
  • 71
1
vote
1 answer

Is it possible to set content-type in angular $resource without body

I'm consuming an API that accepts the following request POST /myulrpath/params?x=2,3 Host: somehost:20200 Content-Type: application/json There is no payload allowed in the requst but it still requires the correct content/type. Im tryng to solve…
Marthin
  • 6,413
  • 15
  • 58
  • 95
1
vote
1 answer

Angular model is null inside resource promise

I am trying actualize an angular model inside a resource promise, but the problem is that this model is undefined. Basically I have list of products that are showing on the page and for all products I have a delete action. I want, after…
grkopiec
  • 13
  • 3
1
vote
3 answers

Response for preflight has invalid HTTP status code 405 on Angular Js1 and Webapi 2

Error: OPTIONS http://localhost:8080//api/home/GetText 405 (Method Not Allowed) http://localhost:8080//api/home/GetText. Response for preflight has invalid HTTP status code 405 angular.js:14362 Error: Error getting home/GetText data from the…
1
vote
2 answers

Unknown Provider in AngularJS $resource

I am getting the infamous unknown provider error, and looked into every potential answer up here but I think that I am missing something: app.js var myApp = angular.module('myApp', [ 'ngResource', 'myAppControllers', 'myAppServices', …
Hasan Can Saral
  • 2,950
  • 5
  • 43
  • 78
1
vote
1 answer

sending headers using $resource in angular js

I want to send headers each time for CRUD operation from factory side. Here is my factory var appangular.module("LifeStyleFactModule",["ngResource"]); app.constant("RES_URL",…
ANK
  • 293
  • 2
  • 10
1
vote
2 answers

Issue with nested resource calls in angularjs

Please excuse me if this is in some way obvious, but I can't seem to find any thing similar in the angularjs docs or on SO. I have an application where there is a table of data, including estimates by month. We are implementing something where you…
zaknotzach
  • 977
  • 1
  • 9
  • 18
1
vote
1 answer

How to set a X-CSRF token in $resource

I'd like to add an X-CSRF token to some $resources, but even though I've been looking to other topic and found taht I could add header this way return $resource(url, {}, { connect: { method: 'POST', …
Antoine
  • 35
  • 7
1
vote
1 answer

AngularJS - Resolved data doesn't refresh in nested state components

I'm using AngularJS 1.5, ui-router, and angular-resource and I am developing a component-based application. I have one parent state, which is used for getting and updating data, this data is bound to multiple child states via a parent state…
1
vote
1 answer

URL param passed as body param with Angular Resource

I am using Angular (1) with $resource. One of my API request is failing because a URL param is passed as a request body param instead. Why is this happening? /** @ngInject */ module.exports = function ($resource, API_URL) { return…
Jiew Meng
  • 84,767
  • 185
  • 495
  • 805