The AngularJS ngResource module provides interaction support with RESTful services via the $resource service.
Questions tagged [ngresource]
525 questions
0
votes
1 answer
AngularJS ngResource $save feedback
Hello I am using ngResource $save method and I get two different behaviours, I don't understand why
First I'm using it in this way:
$scope.user = new User($scope.user);
$scope.user.$save(function () {
$window.location.href =…

Duilio
- 258
- 1
- 10
0
votes
1 answer
ngResource: Object has no method query
Trying to get ngResource to work, but getting the error:
Object # has no method 'query'
I've tried to keep it as simple as possible and according to the documentations/posts that I can find, this should work. But it doesn't.
Here's my…

jkbradshaw
- 25
- 5
0
votes
1 answer
$resource and $promise returning undefined
I get the following error:
TypeError: Cannot call method 'then' of undefined
on this code:
App.controller('MainCtrl', ['$scope', 'Main', 'MainFilter', function($scope, Main, MainFilter) {
$scope.scope_variable = Main.query().$promise.then(…

Steven Harlow
- 631
- 2
- 11
- 26
0
votes
1 answer
"Suggest slug name" API call in ngResource in AngularJS/Express app
I want the user to be able to set the slug name (URL) for a document in my app, but also I need some control so users don't override each other. It needs to be a separate call (not integrated with create/update) so the user can get visual feedback…

Tom Söderlund
- 4,743
- 4
- 45
- 67
0
votes
1 answer
Pass a value from a Resource to another resource as a Parameter
So I've got a resource set up like so.
.factory('ChannelListing', function($resource) {
return $resource('/api/v1/channel_listings.json?channel_id=:channel_id',
{channel_id: '@channel_id'},
{'query': {method:'GET', isArray:false}});
…

Mr. BigglesWorth
- 1,530
- 3
- 18
- 33
0
votes
0 answers
Passing parameters to resources in a factory to access info in controller
So I've set up a factory like so using $resource:
'use strict';
angular.module('hscApp')
/* ----------------------
Test- Using channel_id
------------------------ */
.factory('Data', function($resource){
return {
retrieve:…

Mr. BigglesWorth
- 1,530
- 3
- 18
- 33
0
votes
1 answer
How to pass form data along with angularjs api call using ngresource?
I have my data in json at controller, now i want to send that data to an post api call in service.
service - Article
At my controller :
var annotationScripts = {startOffset : range.startOffset , endOffset : range.endOffset};
Article.post({id:…

Himanshu Goel
- 574
- 1
- 8
- 26
0
votes
1 answer
ng-model with $watch responding only with full strings (AngularJS)
I'm programming a SPA with AngularJS. Right now, I have an input field that triggers a query with $http to a 3rd party API. The search is done on real time as I have a $watch bind with the input model.
My problem is that for whatever reason, the…

Eric Mitjans
- 2,149
- 5
- 40
- 69
0
votes
1 answer
Using a $resource-based data model with controller and directives
I have created a "model"* for my Project data like this:
angular.module('myapp').factory("projectModel", function ($resource) {
return $resource(
"/api/projects/:id",
{ id: "@id" },
{
"update": { method: "PUT"…

Tom Söderlund
- 4,743
- 4
- 45
- 67
0
votes
1 answer
ngResource: Making a POST request to a specific item
I have the following basic API for a forum:
POST /topics (create new topic)
GET /topics (get all topics)
GET /topics/1 (get topic with ID "1")
And I want to add the following:
POST /topics/1 (add reply to topic with ID "1")
I have tried the…

callumacrae
- 8,185
- 8
- 32
- 49
0
votes
1 answer
$resource.query( ) callback result unexpectd
I'm developing angular web app. I want to utilize the error callback of query to inform user that there's some error just happened. But the Result is just not what I expected, below is the controller method:
$scope.fetchAllPlayers = function() {
…

Aaron Shen
- 8,124
- 10
- 44
- 86
0
votes
1 answer
Angularjs - How to combine two objects obtained with ngresource
How to combine two objects obtained with ngressource.
Each 5 seconds, i call my service to obtain a message and i want to add a new message with the olders.
My Json message :
[
{"age": 0,"id": "my first tweet","name": "Hello Sarah","snippet": "It's…

Guillaume.G.
- 1
- 1
- 2
0
votes
1 answer
How to mock the requests made by ngResource in Angular JS
I am trying to begin writing unit tests for my angular application and hit a stopping block pretty quick as I am unsure of how exactly to mock my service in a testable way.
My service is as follows:
var services = angular.module('myApp',…

user3040546
- 3
- 2
0
votes
0 answers
Angular typeahead, filtering, $resource and promises
I'm implementing a typeahead using angular like this:
In my controller, I…

Jennie
- 11
- 1
- 3
0
votes
1 answer
Nesting resources in AngularJS
I'm creating the "Discussions" module of my website with AngularJS.
I've actually two types of resources for client<->server communication :
Discussion $resource (used to retrieve Discussion-related infos, like 'title', 'status', etc. Discussions…

Neozaru
- 1,109
- 1
- 10
- 25