Questions tagged [ngresource]

The AngularJS ngResource module provides interaction support with RESTful services via the $resource service.

Resources

Tags

525 questions
7
votes
1 answer

AngularJS Controller Error - : $http.get is not a function in controller section

var hsbc = angular.module('hsbc',['ngResource','ngRoute']); hsbc.config(['$routeProvider','$locationProvider', function ($routeProvider, $locationProvider){ //console.log('config part working'); $routeProvider .when('/login', { …
Rajesh Kumar
  • 153
  • 2
  • 4
  • 13
7
votes
3 answers

AngularJS Error :Module 'ngResource' is not available! You either misspelled the module name or forgot to load it

I'm trying to make a service call from angular js. I downloaded the angular seed project.And inside the view1.js wrote the following code to call the service: 'use strict'; angular.module('myApp.view1',…
iJade
  • 23,144
  • 56
  • 154
  • 243
7
votes
4 answers

Virtual attributes in ngResource

Is it possible to add virtual attributes to a ngResource? I created a service like this app.factory('Person', ['$resource', function($resource) { return $resource('api/path/:personId', { personId: '@_id' }, { update: { …
pasine
  • 11,311
  • 10
  • 49
  • 81
6
votes
1 answer

Should ALL RESTful API calls be defined in an angular service?

I would like to call the following api routes /api/user/:id /api/user/inbox /api/user/blah Would all of these be defined in one angular service? And how would I do that? every tutorial I've looked at has a service where it immediately returns the…
jory
  • 87
  • 3
6
votes
1 answer

POST a JSON array with ANGULARJS $resource

I need to do send a json array to a restful api from my angularjs application. I am using ngresources to do this. Since now, I have been abled to post and put single object with no problem, but now I need to send an array of objects and I can't. I…
6
votes
1 answer

Passing array style query parameters to a resource in Angularjs

I'm currently working with an API that uses array style query parameters to filter items but I'm not quite sure how to get this working in Angular. In my example below I have a drop down that takes the ng-model of the selection and applies this to…
Mr. BigglesWorth
  • 1,530
  • 3
  • 18
  • 33
6
votes
1 answer

Good example of a put operation using AngularJS $resource

I have been struggling to find a consistent and good example of a put operation using AngularJS $resource. An example of when I want to update, but can't seem to is located here: AngularJS PUT on voting application to REST Service At the core, I…
Kode
  • 3,073
  • 18
  • 74
  • 140
6
votes
4 answers

How do you send x-www-form-urlencoded data with Angular $resource?

I am trying to submit a POST request to a server which only accepts the data in the x-www-form-urlencoded format. When I test it out on Postman, it works. For example, the preview header looks like: POST /api/signin HTTP/1.1 Host:…
Raphi
  • 203
  • 2
  • 10
6
votes
1 answer

Working example of AngularJS $resource searching items in Web Api

I'm learning how to use AngularJS's $resource to call a Web Api backend. I want to pass an object hierarchy in as criteria and get back an IEnumerable. Here's an example of the criteria: $scope.criteria = { Categories:[ { …
adam0101
  • 29,096
  • 21
  • 96
  • 174
5
votes
1 answer

Run a hook before $resource constructs the url?

I want to programatically alter route parameters before $resource constructs the url. I cannot use angular's http interceptor to do this, since the route is already concatenated at that point. Given an Assortment.model.js module.exports =…
5
votes
1 answer

Angularjs ngResource needs to have file as one of the fields

I have resource that has following fields: description, picture Is it possible to send that resource to URL as multipart/form, and if so, how? I've tried putting: app.factory('resource_name', ['$resource', function($resource) { return…
Slaven Tomac
  • 1,552
  • 2
  • 26
  • 38
4
votes
1 answer

Angular $resource get vs $get

I use Angular $resource service and it's not clear for me why there is two different methods for main queries. I can do this: var House = $resource('/house/:uuid', {}); // create resource var houseUuid = '123'; var house = new House.get({uuid:…
WebBrother
  • 1,447
  • 20
  • 31
4
votes
0 answers

How to refresh query array on angular resource

I've got angular set up to talk to a collection of objects with REST, using the $resource framework. Something like this: angular.module('ngBooks', ['ngResource']) .factory('Book', ['$resource', function ($resource) { return…
hwjp
  • 15,359
  • 7
  • 71
  • 70
4
votes
3 answers

Modeling relational data from REST api via angularjs

I'm building an app, that is backed with node-mysql combo, and angularjs on the frontend part. The backend REST service is ready, but I'm struggling with modeling my relational data. There are some questions regarding this like : $resource relations…
mike_hornbeck
  • 1,612
  • 3
  • 30
  • 51
4
votes
1 answer

AngularJS ngResource not sending custom header

I'm attempting to use ngResource to query a REST API. I need to specify my API key in a custom header. I've tried it like so: angular.module('ApiService', ['ngResource']) .factory('Api', ['$resource', function($resource) { this.apiEndpoint =…
Charlie Schliesser
  • 7,851
  • 4
  • 46
  • 76
1
2
3
34 35