The ngResource module provides interaction support with RESTful services via the $resource service.
0
votes
1answer
52 views
Cannot read property 'index' of undefined
I am very new to Angular and was trying to use it on my Rails Application. But I got the following error.
TypeError: Cannot read property 'index' of undefined
app.js code
angular.module('ticket', ...
0
votes
1answer
31 views
AngularJS ngResource $resource query() Returns Empty
I am trying to upload a file from the server but the file is not showing up. The call to the server is initiated from this segment of code:
'use strict';
angular.
module('phoneList').
component('...
1
vote
0answers
29 views
Asp.Net Web Api PUT got a value with all null properties?
I have a big complex C# class
public class D2 {
[Key] public string Id { get; set; }
// ..... Many other properties with type of string, DateTime, Int16?....
public List<Ref1> R1 { ...
0
votes
1answer
16 views
How store AngularJS $resource calls in an array to execute all together after?
I'm working with AngularJS 1.5 (I'm really beginner with JS) in a user profile view where the user can change a lot of things in his data.
In this view the data is split in several sections and save ...
2
votes
1answer
65 views
Extending $resource object removes prototype from Factory
Here is the code that I have right now:
// Factory
angular.factory('Student', function() {
var defaults = {
StudentId: null
};
var Student = function(params) {
angular....
0
votes
1answer
23 views
Angular injects module causing bind fails
I have recently started a new project on angularJS.
I have an index.html which basically render all the script files when started.
There is a ng-view inside, the home.html will be loaded by ngRoute ...
0
votes
0answers
20 views
Angular Js Resources encodeUriSegment Issue
I am using Codecraftpro to make a CRUD Application.
When I am trying to update the existing record I am getting the following Error (see attached image):
Console output
0
votes
1answer
35 views
How to post some data and get results using MEAN stack and ngResource
I am working on a application and I am using MEAN stack as technology. In AngularJS, I am using ngResource to CRUD operations. Can any one suggest how to send username and password to server and get ...
0
votes
0answers
131 views
$resource with authorization header
how can i pass authorization token in $resource request header. I have already tried many ways like :-
$resource('url/to/json', {}, {
get: {
method: 'GET',
headers: { 'something':...
0
votes
0answers
37 views
$resource: sending paramDefault data in POST request
I am attempting to send variables to an action in a resource, but I cannot figure out how to correctly configure the paramDefaults! This all goes to the route POST /api/users/:id/ratings, which prints ...
1
vote
1answer
35 views
Get the actual URL used during for an Angular $resource action
Is there a way to find out the actual URL used during an action method call of an Angular $resource? I'm trying to decorate the default factory to implement my own caching mechanism for resources as I ...
1
vote
1answer
62 views
Angular Resource parameters not passing
When making POST using a Resource Service in Angular, it appears to not be sending the parameters along with the request. The Service worked fine, before I added a second function (limit, offset) ->...
1
vote
1answer
51 views
AngularJS multiple resource call, handle last one only
Hi ive a menu where each button in the menu makes a resource(REST) call. Ive a case where the user clicks button A and then fast clicks button B. In this case I only want to handle the last call and ...
1
vote
1answer
48 views
Angular get data from MVC JsonResult
I have the following Action in my MVC Controller:
[HttpPost]
public JsonResult Save(TestModel model)
{
var newId = _myService.CreateItem(model);
return Json(newId);
}
This runs and returns ...
0
votes
0answers
18 views
angular $resource transformed nested array to an incorrect type
My restful api return data like:
[
[{}, {}],
[{}, {}]
]
However, when I tried to get it from $resource's response, it has been transformed to:
[
{
"1": {},
"2": {}
},
{
"1": {}...
0
votes
1answer
120 views
Angular “Response is undefined” when attempting to implement a global error handler for a resource
I'm new to angular and attempting to create a global error handler. Any time a resource is called with a 500 http status, I'd like to redirect to a generic error page.
Whenever I implement an ...
0
votes
1answer
133 views
angularjs get the error message from the service to the controller
Factory that gets the rates using REST
.factory('rateResource', ['$resource', function ($resource) {
return $resource('/rates/:currency/:effectiveDate', {
currency: '@currency',
...
1
vote
1answer
491 views
AngularJS - XX is not a function
In AngularJS I have Controller as follows:
function LoginController($scope, $rootScope, $location, $cookieStore, UserService) {
$scope.rememberMe = false;
$scope.login = function() {
...
1
vote
2answers
41 views
Updating $scope in an Angular directive
I m using the following, after much frustration and Googling I cannot get the data_banks item to update in the $scope after the $resource for Marketplace.buy has been loaded successfully;
myApp....
0
votes
1answer
192 views
Add common parameter in each http request
Suppose that all of my Rest API need to accept following parameters:
1) param1
2) param2
It would be tedious for me to implement this way (refer to code right below).
Moreover, it defies the ...
2
votes
1answer
123 views
Unable to use $update, $remove and $save in ngresource
I am using ngresource as follows but unfortunately I am unable to access the $update, $remove and $save methods in this way. What am I doing wrong?
angular.module('myApp.services').factory('Entry', ...
4
votes
1answer
1k views
AngularJS - $cancelRequest not available in $resource
I am trying to fire abort request however, I am not getting $cancelRequest object in result of $resource. But, I am able to get $promise and $resolved objects.
Why is this happening? How can I get ...
1
vote
1answer
47 views
How to update angular resource urls with id from the authenticated user?
So I have defined multiple angular factories with ngResource similar to:
.factory('factoryName', ['$resource', '$http', 'CONSTANTS', 'authService', factoryNameCtrl])
function factoryNameCtrl($...
0
votes
0answers
432 views
Angularjs resource service bad request (400) with post and put
I am trying to send object into server side using post in AngularJs.I am having a hard time every time i make a REST call it gives me a responded with a status of 400 (Bad Request) error.I have used ...
1
vote
0answers
57 views
How to put custom url in angularjs $resource?
This is my angularjs service:
app.service("ConfigurationMasterService", function($resource){
return $resource('/configurationMasters/crud/:id',{
id: '@id'
},{
saveConfig : {
action : ...
5
votes
1answer
70 views
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 ...
1
vote
2answers
98 views
Pass ID to webservice from angular factory
I am new with angular and working through some problems. While I know this is a small issue i'm struggling with the syntax on how to pass my parameter to my web service from my factory. My error is ...
1
vote
1answer
188 views
Factory patterns and ngResource
I have a factory that provides access to a resource object as shown below. Initially, I had this implemented inside a controller, but moved it up into a factory to make it more reusable across my ...
0
votes
2answers
121 views
How to inject service into gridApi event?
I have a ng-resource service in my controller (let's call it Items):
app.factory("Items", function($resource) {
return $resource("/api/items/:id");
});
Want to make a POST request to save edits ...
2
votes
1answer
829 views
How to set default header values in Angular Resource?
The following approach does not work:
angular.module('myApp.myModule').factory('MyResource', function($resource, $cookies) {
var token = $cookies.get('token');
var user = $cookies.get('...
0
votes
2answers
263 views
Using the $resource as alternative to http in Angularjs not working
I am learning Angularjs and in my first application I am replacing the $http with $resource and getting error. The below was my earlier service and the current service:
angular.module('myApp')
....
0
votes
1answer
84 views
AngularJS $resource returns [d{…}]. What is it?
If I console.log $resource, I get something back I don't understand.
$scope.results = $resource(url, {}, {withCredentials: true}).query(function(arg) {
console.log(arg);
});
returns:
LOG: [d{id: '...
0
votes
1answer
87 views
How exactly means this $resource web service connection configuration in AngularJS?
I am absolutly new in AngularJS and I am studying a tutorial that show how to access to this external weather forecast API: http://openweathermap.org/forecast to retrieve and use weather information.
...
0
votes
0answers
59 views
Angularjs $resource Cache
I have a more generic implementation of $resource as "Datarepository" factory in my application and all the REST API calls calls this factory to do the "REST" operation
myapp.factory('DataRepository',...
1
vote
1answer
31 views
Angular JS and Cross Origin Requests
I am just playing around with angular JS and wiring it up to some restful web services I have implemented. I have moved onto using the $resource module provided by angular and have a simple question (...
1
vote
1answer
392 views
How to use @id in $resource object in angularjs
I am using $resource in angularjs to call my rails api and when i call this route using angularjs $resource object like this
.factory('playlists',['$resource', function($resource) {
return $...
0
votes
2answers
31 views
AngularJS extend default get of $resource?
I have thin service wrapped around $resource to handle communication with API. Usually it works just as needed. However now I would like to extend get from $resource.
Let's say that front end need ...
0
votes
1answer
48 views
Using $resource with rest service
I'm trying to get familiar with $resource in order to use RESTful Web Services.
So, for the attempt, I declared a factory like this :
'use strict';
angular.module('BalrogApp').factory('Req', ['$...
0
votes
1answer
666 views
Pass Multiple parameters Angularjs resource
I have UsersService.js
app.factory('UsersService', function($resource) {
return $resource('api/users/:id', {}, {
update: {method:'PUT'},
});
Along with Index.php (API with PHP Slim Framework)
.....
0
votes
1answer
75 views
Angular array filter
I have this code
function GuestWizardController($scope, ApiResourceBed, ApiResourceRoom) {
$scope.rooms = ApiResourceRoom.query();
$scope.showBeds = function( roomId ){
$...
0
votes
2answers
364 views
Kendo Chart is not loading in AngularJS
I am using Kendo and Angular together. I am using Kendo Charts to display some data got from the database. I have a simple service using Angular $resource to get the data from the storage. It looks ...
1
vote
1answer
951 views
AngularJs $resource.query() gives TypeError: href is null
I am using angular $resource.query to retrieve json data over REST. When I call the query() method a GET request is sent to the server and successfully retrieves the json data:
{
"_links" : {
"...
0
votes
1answer
39 views
ngResource default parameters from promise
I have several rest services that looks like this
/user/:userId/resource/:resourceId
Most of the time the user wants to get his own resources (although sometimes he wants to get anther user's ...
2
votes
0answers
281 views
AngularJS DELETE with Tomcat causes 405 Request method 'DELETE' not supported
I'm using Spring Data Neo4j Rest backend served on Tomcat (8.0.27) with Angular frontend, all served locally at http://localhost:8080/. When I try to delete a record with either $http.delete() or with ...
0
votes
1answer
75 views
Expected response to contain an array but got an GET
I researched this question everywhere but no solution is working for me.
like this: Error: [$resource:badcfg] Error in resource configuration. Expected response to contain an array but got an object?
...
0
votes
1answer
21 views
AngularJS $resource in a simple factory
I am trying to learn AngularJS in baby steps and I'm falling down a lot. In my controller, this works:
var svc = $resource('MyService/dimensions');
$scope.NumDen = svc.query();
When I try to put it ...
1
vote
1answer
42 views
Angular POST JSON structure
When I submit an empty form from my angular app, it sends out the following JSON:
{foo: {}}
This leads to a 500 error (instead of 422) from my server, as it expects the following structure:
{foo: {...
1
vote
1answer
223 views
AngularJS $resource Headers POST
I would like to know how to pass headers to AngularJS $resource method
Here is the factory method
.factory('DataRepository', function ($resource) {
return $resource(serviceUrlPrefix + '/...
1
vote
2answers
60 views
Passing parameters from view to another view with another controller
I'm trying to make a call to a REST API, passing two params to another view and another controller.
The syntax is /api/:id/something/:id2/something.
on the receiving end I have a factory that will ...
0
votes
1answer
602 views
catch errors/read status code from rest call - angular
How do you catch errors/read http status code when making a rest call in one of these formats, both work to return a successful response, just no idea how to grab the info i need. I can get the ...