The tag has no wiki summary.

learn more… | top users | synonyms

19
votes
3answers
8k views

How to refresh / invalidate $resource cache in AngularJS

I have a simple User $resource that uses the default $http cache implementation like so: factory('User', function($resource){ return $resource(endpoint + '/user/current/:projectId', {}, ...
11
votes
2answers
5k views

Angular - extending $resource subobject with custom methods

In most cases the result of <custom-resource>.query() method is an array, which can be easily extended with some methods (business logics) with the following (factory) code: var Data = ...
9
votes
2answers
2k views

AngularJS and complex JSON returned by django tastypie

I have few resources written on AngularJS that access a Tastypie API. Everything works fine, except for a detail: tastypie always encapsulate the actual result inside a objects attribute on a JSON, ...
8
votes
2answers
733 views

Angular Resource - how to check if a resource instance has any unsaved changes?

I want to be able to tell whether an $resource instance has been modified by the user - that is, whether its current state is different than what has been initially loaded from the server && ...
7
votes
2answers
2k views

How can I extend the constructor of an AngularJS resource ($resource)?

I have a model, defined using $resource, that I am successfully loading. Each loaded instance is, as promised, an instance of the class I defined. (The example below is from the Angular docs. In ...
6
votes
3answers
4k views

Angular: Custom headers are ignored by $http and $resource. Why?

I'm trying to access a REST service I don't control. First problem is that the service doesn't include a Access-Control-Allow-Origin header, which is a problem that, if I understand correctly, ...
5
votes
2answers
705 views

How do I not send url template parameters with request body in angular?

Suppose I have a resource set up like this: resource = $resource( "http://foo.com/service/:type/:id", {}, {save: {method:'PUT', params: {type:'@type', id: '@id'}}} ); ...
5
votes
4answers
8k views

How to configure Angular $resource (ngResource) to pull data from another domain using CORS

I'd like to be able to setup resources using $resource using CORS to request my data. I've got CORS working with $http but the same techniques don't apply to $resource and I was hoping someone can ...
4
votes
1answer
3k views

Protractor times out waiting for sync with page when using $resource

I'm testing Protractor with a small AngularJS app. This is the test: describe('Testing Protractor', function() { var draftList; it('should count the number of drafts', function() { ...
4
votes
2answers
3k views

'Best' practice for restful POST response

So nothing new here I am just trying to get some clarification and cannot seem to find any in other posts. I am creating a new resource restulfully, say: /books (POST) with a body: { title: ...
4
votes
1answer
2k views

AngularJS Resource - PUT method is not getting the id

I have a factory that returns the $resource for my Article model: angular.module('ADI.Resources').factory("Articles", ['$resource', function($resource) { return ...
4
votes
1answer
68 views

AngularJS app freezes during query

I am running an Angular app with a Parse backend. When I make a query, the app freezes, even when the DOM doesn't depend on the data being grabbing at the time. That is why this answer was not so ...
4
votes
2answers
441 views

AngularJS $resource url causes “question mark” ? to appear with no params

I have a $resource that defines a custom url for the :all method. angular.module('MyApp'). factory('Object', ['$resource', ($resource) -> $resource( ...
4
votes
1answer
329 views

Active Record or Data Mapper pattern for Angularjs?

I'm very new to Angular, so hopefully I know enough to ask what seems like a reasonable design question. I'm charting some data via Angular, and am using $resource. Before bringing Angular in to the ...
3
votes
3answers
3k views

add a custom function on angular $resource

I have an angular resource that goes something like this app.factory('User', function ($resource) { return $resource( '/api/user/:listCtrl:id/:docCtrl/', { id: '@id', ...
3
votes
1answer
4k views

CORS with angular.js $resource and ServiceStack Servies

i've a servicestack REST Service and a angular.js client. The Web is hosted on an other port then the RESTService. Retrieving data with $http works but using $resource doesn't work. in the REST ...
3
votes
1answer
3k views

How to use an angularjs resource for rails/RESTful routes?

I've got an angularjs app embedded in a rails app. I'm using the RESTful methods provided by rails for a resource named "Task." Here are the routes I'm dealing with: GET /api/v1/tasks.json POST ...
3
votes
2answers
2k views

ngResource resolving nested resources

What options are there there for resolving nested resources in ngResource responses? There have been some related questions about resolving endpoints for nested resource in ngResource, but this ...
3
votes
3answers
2k views

AngularJS 1.2.0 $resource response is empty

I'm using AngularJS 1.2.0. When I'm calling a webservice with $resouce the response variable is always empty. The webservice is called correctly and the webservice is sending the result to the ...
3
votes
1answer
110 views

Set $resource transformResponse after initialization

Is there anyway to set the transformResponse after initialization of a $resource? I basically have an extended $resource, but I want to attach a transformResponse to the extended version, and not the ...
2
votes
1answer
2k views

Angular 1.0.8 $resource with multiple optional get parameters

My Student ulr looks like this: var Student = $resource('/app/student/:studentid:courseId', {studentid:'@id',courseId:'@cid'} ); When I call it without parameters I would like the url be ...
2
votes
2answers
152 views

Handling $resource with AngularJS and MVC.NET

I'm using an AngularJS $resource to contact MVC ActionMethods on the server. The resource URL is /api/customer, so for the $resource.query function I provide an ActionMethod called Customer on the ...
2
votes
2answers
298 views

How do I get a null response from a $resource?

How do I get a null response from a $resource? I am running this: angular.module("services").factory('Member', function($resource) { var Member = $resource('/api/v1/member.json'); ...
2
votes
2answers
1k views

AngularJS ngResource delete event

I'm trying to keep a list of resources up to date as a user interacts with it. Using an AngularJS ngResource I initially grab the list using it's query method. Each resource then has a $remove (or ...
2
votes
1answer
229 views

Adding PUT to default NG-Resource Actions in AngularJS

I am trying to add PUT to the default methods in ng-resource. So far I modified the DEFAULT_ACTIONS to: var DEFAULT_ACTIONS = { 'get': {method:'GET'}, 'save': {method:'POST'}, ...
2
votes
1answer
198 views

Angular $resource endpoint with two parameters

I've got a setup using a service to handle $resource that is as follows: Service factory('EventSlot', ['$resource', function ($resource){ return $resource('/api/events/:id/slots/:slotId', {id: ...
2
votes
2answers
554 views

TypeError: undefined is not a function in Angular Resource

When trying to poll a custom method copies on an AngularJS Resource I get the following error at angular.js:10033: (The method copy works just fine.) TypeError: undefined is not a function at ...
2
votes
1answer
53 views

What is the difference between Class actions and Instance actions in AngularJs?

From the docs: Class actions return empty instance (with additional properties below). Instance actions return promise of the action The documentations however doesn't clearly differentiate ...
2
votes
1answer
47 views

Angular $resource: Unknown Provider error, loading dependancies and angular elements

Been doing rails for about a year but this is my first real angular app. So far I've been mostly piecing things together from tutorials, but I'm having troubles. I've searched through other SO ...
2
votes
1answer
975 views

AngularJS: transform response in $resource using a custom service

I am trying to decorate the returned data from a angular $resource with data from a custom service. My code is: angular.module('yoApp') .service('ServerStatus', ['$resource', 'ServerConfig', ...
2
votes
2answers
282 views

AngularJS: Unable to get responseHeaders after a $resource $save

I'm performing the following $save which calls my angularJS $resource and POSTs to my API. I'm able to debug into my success callback handler and the object is actually created in my API. ...
2
votes
0answers
80 views

Send null as a value in ngResource AngularJS

I'm using AngularJS 1.2.1's ngResource and I'm trying to send null as a value in the parameters in a PUT request. Unfortunately, when it is set, Angular will ignore it the parameter and not send it. ...
2
votes
2answers
64 views

How to get access to resource URL params with ngResource?

I have an AngularJS service for handling buildings, using ngResource: angular.module('neighborhoodApp') .factory('Building', function ($resource) { return $resource('/areas/:aid/buildings/:id', ...
2
votes
3answers
2k views

Angularjs resource factory transformResponse is not called

Below is my code MY_MODULE.factory("SOME_API", ['$resource', '$http', '$rootScope', function($resource, $http, $rootScope){ return $resource("/appi/get/", {responseFormat: 'json', ...
1
vote
1answer
276 views

AngularJS - Unknown Provider

I'm trying to create a small note-taking application using AngularJS, but I stumbled at the very beginning. Here's my .js file: var app = angular.module("app", ['ngResource']); app.factory("note", ...
1
vote
2answers
2k views

AngularJS resource factory always returns empty response

Ok, so I think I'm missing something basic here but I couldn't figure it out reading the docs and other examples. I have a resource in a factory like this: loteManager.factory('Lotes', ...
1
vote
3answers
33 views

Pass var to angular $resource success function

I've been going crazy over this and I think the answer is probably out there but I don't know the right way to ask Google the question. Essentially I need a way to make a $resource call, and pass in ...
1
vote
2answers
227 views

Combining resources in AngularJS

I have a RESTful API that provides me with employees and departments. In my AngularJS app, I need to know the employee and the departments the employee belongs to. I have defined two factory services ...
1
vote
2answers
224 views

Iterating over JSON returned by a Service on angular

I am trying to iterate over and search by id and return the other values corresponding to the id from a JSON object of the type shown below, by $resource in the controller. I am not understanding ...
1
vote
1answer
273 views

Why isn't my $resource error handler called when I have a responseError interceptor?

I'm building my first Angular app, and I've run into a problem. I have an AngularJS resource whose .get I call with both a success and error callback, like so: var new_uptime = Uptime.get({}, ...
1
vote
2answers
2k views

How to read response from angular resource $save() and also keeping original data

I am new to Angular. I am sure I am missing some basic stuffs here. I have one object which i post to server to create it. Server return object Id; which I need to read and update my object I have in ...
1
vote
1answer
947 views

Angularjs, $resource: how to get inserted object?

I need to get an inserted object immediately after insertion has been done. But this is a problem with Angularjs $resource. module.factory('SearchQueries', function($resource){ return ...
1
vote
1answer
83 views

How to pass body payload to angular $resource DELETE call

I have standard angular $resource configured as such angular.module('client.resources') .factory('ProjectSubjectResource',['$resource', function ($resource) { release: { ...
1
vote
2answers
60 views

AngularJS: Promises & conditions based on results

I have a complex promise chain, with each of the success handlers in then making some more API calls and passing on the results to the next then and so on. I've come to a situation where, based on a ...
1
vote
1answer
350 views

Get response header in then() function of a ngResource object's $promise property after resource resolved?

I'm willing to retrieve the response header of a resource request, cause I've put pagination information and something else in it rather than the response body, to make the REST api clear. Though we ...
1
vote
3answers
115 views

Angular $resource doesn't call get

Just trying to get a very simple REST get call to work using angularjs $resource service. The API is never called. Here is the code: angular.module('app.services', []) .service('tourRepository', ...
1
vote
2answers
68 views

How do I access $scope in chained $request promises?

I have a promise chain that looks like this ... this.getFile(fileId).then(updateFile).then(displayAllDoneMessage); where getFile() and updateFile() each use ngResource to construct the appropriate ...
1
vote
1answer
83 views

Why the difference in using common and post for changing the ContentType should affect the request payload / form data?

If I use the following: a) angularApp.config(function ($httpProvider) { $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; ...
1
vote
1answer
313 views

Scope.attribute available but scope.attribute.variable undefined in directive

I'm trying some angularJS development, but I'm facing a issue that I do not understand at all. I try to format a JSON into a specific table with many rules. For now my JSON look like: { ...
1
vote
1answer
2k views

AngularJS $http DELETE request Content-Type header

When I make a DELETE request with AngularJS $resource module, angular adds a Content-Type: application/xml header to request headers. In AngularJS source code, there is a section that removes ...