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

Resolving relative $resource path in Angular 1.5

My Angular 1.5.8 web application is at http://www.example.com/foo/ and my RESTful list of bars is at http://www.example.com/foo/api/bars. When ui-router goes to the list of bars in Angular, my browser is at http://www.example.com/foo/#/bars. I…
Garret Wilson
  • 18,219
  • 30
  • 144
  • 272
1
vote
1 answer

Is there any way to set the custom header when making a API call?

I want to add custom header at the time of API call. I am actually calling a function from controller and inside that function the $resource object is going to be set as follows: // Generate the $resource object based on the stored API object …
SaMeEr
  • 361
  • 2
  • 7
  • 22
1
vote
1 answer

data is undefined in transformRequest using $resource

I'm working on a small project with MEAN in order to get started with it. I've been following the tutorial on thinkster.io (with some minor modifications made by me) and so far I've obtained good results. I've tested the API routes with Postman and…
hrivera
  • 13
  • 5
1
vote
2 answers

How can I find out how many records are in the list after AngularJS $resource query()

I'm struggling with something that I think should be pretty simple. I want to see how many items are returned from a query() but using length isn't working for me. This my code getItems = function () { // retrieve the list …
Damian
  • 1,652
  • 4
  • 26
  • 44
1
vote
2 answers

$cancelRequest is not a function

I'm using angularjs 1.5.8. I get this error when I'm trying to cancel an http request with angular : $cancelRequest is not a function My code : app.factory('User', function($resource) { var getUsersResource = $resource( '/users', …
Nan
  • 63
  • 1
  • 9
1
vote
1 answer

Laravel and AngularJS existing email verification within resource

I am trying to create a new user with AngularJS form and Laravel as backend, the functionality works as expected with exception to checking for users with existing email. Below is my Angular Factory, Controller function for ngSubmit and Laravel…
Rohan Krishna
  • 75
  • 2
  • 11
1
vote
1 answer

Error in Angular Resource Configuration - isArray is True

I've got a bit of a pickle that I hope you can help out with. I'm, working on making an Ionic version of an Angular web application that I have recently build. Since it is essentially the same angular between the two, you would think they would…
mcheli
  • 35
  • 1
  • 6
1
vote
2 answers

How to load data in ng table from REST web service that return a JSON

I want to load my table from a JSON that returns my REST web services in SpringMVC, but I get the following error that says that my rest method doesn't support the GET method. The URL that my controller have mapped is this one…
Bill_Data23
  • 659
  • 2
  • 14
  • 30
1
vote
1 answer

Angular $resource - accessing to returned resource.$promise in TypeScript

I'need to access the $promise property of object returned with some default action on $resource (e.g. remove, query...). But it seems it is not possible in current TypeScript definitions for $resource: Example: I have a student resource: interface…
Dominik Palo
  • 2,873
  • 4
  • 29
  • 52
1
vote
1 answer

Get data by angularjs $resource

I have the following angularJS function that get data by $resource ,it works and push this data to vm.data array, ,but when I try to get vm.data in controller i get null ,This last line of the following code print null value function loadAll() { …
Ali-Alrabi
  • 1,515
  • 6
  • 27
  • 60
1
vote
0 answers

May i know call rest api angular js

This is the url I am working with: http://103.13.75.21:8081/product I have tried: