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

Implementing Angularjs search filtering in Rails app

I have a Rails app I'm working on that is a database of APIs: http://hapily.herokuapp.com/ It already has a working search box I've made in Rails, but I'd like to use angular.js to make the search work without leaving the home page. I can't seem to…
Sara
  • 2,729
  • 7
  • 22
  • 30
3
votes
1 answer

Cache Data with $resource promises pattern

Assuming my service is returning a promise from a $resource get, I'm wondering if this is the proper way to cache data. In this example, after hitting the back arrow and returning to the search results, I don't want to query the webserver again…
lucuma
  • 18,247
  • 4
  • 66
  • 91
3
votes
2 answers

$resource update method behaving strangely

Reading/Creating/Deleting is all working fine for a particular $resource, however Editing is not going so well. In my app config I have: $httpProvider.defaults.headers.post['Content-Type'] =…
DanH
  • 5,498
  • 4
  • 49
  • 72
2
votes
0 answers

Firefox performance profiler | Not showing useful information for ~5 secs

In my Angular JS app, when hitting an HTTP request I am observing lags of ~5 secs. This happens when large data is sent in the request. More the input data, more the lag. Additionally, this is observed only in Firefox. All other browsers don't show…
Manu
  • 901
  • 1
  • 8
  • 28
2
votes
1 answer

Unable to set href in angular 4 on nginx server

Please bear with me as it's a long question but I am stuck badly. Objective I want to ran my ssl configured build on my linux based server on Nginx and I want to access it on my domain https://dev.server.nl with resources /ggmd/webconsole i.e…
2
votes
1 answer

Waiting until $resource finished to load in my controller before continuing

I'm building a rest api with fosrestbundle and I manage the frontend with angular and Twig template. One on my url address looks like this : http://mywebsite/myroute/idContain When I load the url in my browser, in a twig template (kind of html), I…
kabrice
  • 1,475
  • 6
  • 27
  • 51
2
votes
0 answers

Asp.net identity Share authentication cookie of MVC app with AngularJS

I am using ASP.NET MVC and AngularJs. I need to authenticate. I authenticate using the default code of the MVC Project in VS2015. Here the View:
@using (Html.BeginForm("Login", "Account", new { ReturnUrl =…
Simone
  • 2,304
  • 6
  • 30
  • 79
2
votes
2 answers

$resource resolve in ui-router error catching don't fail state

I am running a ui-router with a resolve in it, and the resolved data looks like this: myService: "myService" items: function(myService){ var promise = myService.resource.query().$promise; return promise; …
pasquers
  • 772
  • 1
  • 8
  • 24
2
votes
3 answers

how to use $resource to get the data from local json file

I am trying multiple ways to access my users in a local json file in able to later compare them to the users input. and if there is a match, access is allowed, but my main problem now is just getting to those users. My code so far: entire…
KashaCathy
  • 23
  • 1
  • 3
2
votes
1 answer

POST request using angular $resource

In my index.js file I have the following POST... router.route('/bears') // create a bear (accessed at POST http://localhost:8080/api/bears) .post(function(req, res) { var bear = new Bear(); // create a new instance of the Bear model …
buydadip
  • 8,890
  • 22
  • 79
  • 154
2
votes
1 answer

AngularJS $resource - adding array element to paramDefaults

I'm using the twitch.tv api and using the Angular $resource factory. The endpoint I'm trying to use is: GET /channels/:channel. What I'm trying to do is get the channel for each array element. I tried /channels/users[1] but I know this is wrong. How…
labanch
  • 29
  • 5
2
votes
1 answer

add new object to json-server; AngularJS

I have an angular app that supposed to work with json-server for retrieving data and adding new data (users feedback). so I have json database with some arrays and one of them is "feedbacks":[] which is currently empty. on PUT method I get: PUT…
Amir-Mousavi
  • 4,273
  • 12
  • 70
  • 123
2
votes
2 answers

Not able to access property of an object

I'm using $resource for making restful request to the server. My code is service.js .factory('userServ',function($resource){ return $resource('url/:id',{id:'@id'},{ me: 'GET',isArray:false,url:'url2'} }); }) I'm using this service in…
I'm nidhin
  • 2,592
  • 6
  • 36
  • 62
2
votes
3 answers

Testing Angular-Resource: Expected an Object, got a Resource

When trying to test some simple angular code using $resource, I end up with a Resource object which contains a $promise key and hence a failure of the form: Failure/Error: Expected Resource(...) to equal Object(...) I was expecting to get back the…
sunless
  • 597
  • 5
  • 19
2
votes
1 answer

Recall $resource factory within interception

I have the following factory: .factory('Request', ['$resource', 'general', function ($resource) { return $resource(baseURL + ':resourceName/', {}, { get : { method : 'GET', …
Asqan
  • 4,319
  • 11
  • 61
  • 100