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

AngularJS: custom $resource actions don't work

I'm trying to define a custom getUsers action to a $resource, but I get an error that the object has no getUsers method. angular.module('myApp') .factory('Customer', ['$resource', 'apiUrl', function ($resource, apiUrl) { return…
Gal Ben-Haim
  • 17,433
  • 22
  • 78
  • 131
0
votes
0 answers

Async POST request inside angular.forEach

Making an Async post request inside .forEach is causing me a lot of problems. With or without the use of $resource I will get data lose. Or maybe the server just can't get all the requests processed at the same time, I don't really know. Here is the…
sebastiannm
  • 565
  • 1
  • 5
  • 14
0
votes
2 answers

AngularJS/ JS How do I access variables outside my function?

I'm trying to access the variable np defined from within a function block; however, I am running into some issues when I call this.items.push(plumbers). I get TypeError: Cannot call method push of undefined myApp.factory('np', function($resource,…
Ryan W Kan
  • 380
  • 3
  • 16
0
votes
1 answer

ng-resource url parameter does not work

$resource is not correctly passing along a url parameter when making a PUT request, via custom action. This is my service creating the resource. .factory('cartItemsService', ['$resource', function($resource) { return…
Andre
  • 1,292
  • 1
  • 17
  • 34
0
votes
1 answer

Can't figure out why ng-resource won't return array

I am using AngularJS and NGResource and I can't figure out why when I use query, I keep getting an empty array back. In my controller, I am doing Task = $resource('/tasks'); var tasks = Task.query(function () {}); console.log(tasks); $scope.tasks =…
ruevaughn
  • 1,319
  • 1
  • 17
  • 48
0
votes
1 answer

Can't extract data from controller for angular-chosen

I need to use angular-chosen to customize a drop-down of groups for a project. I use resource to share the data between the controllers. I am able to extract the group list to $scope.allgroups of my controller. The console.log shows me this image :…
iRaghu
  • 93
  • 9
0
votes
1 answer

Angular since 1.1.1 returned resource hash as separate symbols

In stable 1.0.7 version all is working perfectly: Here is my resource (with Rails as backend): app.factory "Post", ($resource, apiPrefix) -> $resource( apiPrefix + "/posts/:id", id: "@id" , update: method: "PUT" ) And in all…
gambala
  • 211
  • 2
  • 9
0
votes
1 answer

Tooltip misplaced inside ng-repeat

The following shows the tooltip text in the right place: %a{:href => "http://google.com/"} %span{:tooltip => "TEST"} = "test" The following shows the tooltip half a screen below (increasing distance for each element) %div{:"ng-repeat"…
Sjors Provoost
  • 1,921
  • 1
  • 19
  • 34
0
votes
1 answer

How to use data from $resource in a query for another with Angular

I'm still learning Angular and am having some trouble accessing and using data across $resources. I have two api calls with two sets of data: wagers and users. url:/users/me returns current username and id as an object /wagers returns all wagers as…
user2188552
  • 1
  • 1
  • 1
0
votes
1 answer

Controller with ngResource method called indefinitely

I decided to start learning AngularJS by making a simple app. The server-side application is built with ExpressJs, but the resource used below (/movie/:id) are not implemented yet, so pointing to this URL will result in a 404 (Not Found) error. So…
Laurent Dezitter
  • 710
  • 1
  • 8
  • 16
0
votes
2 answers

Calling a specific method in my Web API controller

So I'm trying to make a call to this specific method: [HttpGet] public int GetLogin(string u, string p) { UserLogin uL = new UserLogin(); return (int)uL.Authenticate(u, p); } However it keeps calling this method in my Controller…
0
votes
2 answers

How to access the RESTful services from external server in my server in angularjs

I am running on domain server1. I have my RESTful services on server2. I want to access this RESTful service on my webpage using angularjs. I tried this way. But it's returning an empty array. No data was bind. Why? any suggestions. Here is my…
anilCSE
  • 2,461
  • 3
  • 23
  • 29
0
votes
2 answers

Using resource to populate scope property in Angularjs

DISCLAIMER I'm coming from knockout so I'm having a little trouble switching my train of thought on how to do certain things, this being one of them... I have an that a user can enter a movie title in and a list of movies should be…
bflemi3
  • 6,698
  • 20
  • 88
  • 155
0
votes
1 answer

Wrap resources in a single service in angularjs?

Recently I found a TokenHandler that allows me to send a token on every rest api request. You can find a detailed description here: http://nils-blum-oeste.net/angularjs-send-auth-token-with-every--request/#.UXtYlbVTDIX I am facing an issue…
DarkLeafyGreen
  • 69,338
  • 131
  • 383
  • 601
0
votes
1 answer

How to update item from $scope ng-repeat after saving using $resource

I have an angular view which displays a list of items and for each there are two buttons that set each campaign on pause/start. I know it's a very basic problem with angular $resource, but I can't update the item on success $start (in the success…