FAQ Database Discussion Community


ngRepeat not updating even though $resource has

angularjs,angularjs-scope,angularjs-ng-repeat,ngresource
I have an "add friend" dialogue, when you add a user it goes back in the state history and should update the friend list. Everything works fine, except that the list doesn't show the new user - even though both console.logs show the correct data: [e, e, e, $promise: Promise,...

Using $resource.query on an array of objects

angularjs,ngresource
Json [ { "id":"0", "name" : "BCAA & GLUTAMINE", "brand" : "NRG FUEL", "price": "20", "description": "NRGFUEL 100% BCAA & Glutamine powder has been scientifically formulated to promote full muscle recovery, growth and repair whilst preventing muscle breakdown. Consisting of our instantized BCAA (2:1:1 RATIO) and absolute pure glutamine NRGFUEL’S...

So I have angular from bower, now what?

json,angularjs,module,bower,ngresource
I just started a new project, these are the exact steps I have taken. foundation new project_name --libsass bower install angular --dev grunt build All good, the sass files are compiling, angular is setup under bower_components inside the angular folder, but wait..... Now I need to add Angular's ng-resource module....

ngResource makes a request but does not parse results

json,angularjs,rest,ngresource
I am working on a webapp that uses ngResource to fetch backend data. Here is my factory App.factory('MyCoolResource', ['$resource', function($resource) { 'use strict'; return $resource('/rest/MyCoolResource'); }]); Then in a Controller console.log("Query: " + MyCoolResource.query()) In Chrome network inspector I can see the data coming back (an array of String) ["Foo","Bar","Gaz","Waka"]...

AngularJS $resource Custom Action for Requesting a Password Reset

angularjs,rest,ngresource,angularjs-1.3
I'm just starting to use ngResource in a project to consume my RESTful endpoints. Is this how you would implement a user password reset using $resource? Looks weird passing the email address as a URL parameter. .factory('User', ['$resource', function ($resource) { var paramDefaults = {id: '@id'} var actions = {...

angularjs, ngResource in a factory and network calls

angularjs,ngresource
Trying to get my head around this. I have a simple factory using ngResouce, like this: .factory('FooResource', function($resource) { var foo = $resource('/api/foo').get(); return foo; }) And in my app, in multiple places, in multiple controllers over time, I use the value of 'FooResource.bar' (where 'bar' is returned in the...

AngularJs (ngResource ) : Error: [$injector:modulerr] http://errors.angularjs.org/1.3.15/

angularjs,ngresource
I want to use ngResource with HTTP but i have this error : Error: [$injector:modulerr] http://errors.angularjs.org/1.3.15/$injector/modulerr?p0=myApp&p1=%5B%24injector%3Anomod%5D%20 Here is my code : <!DOCTYPE html> <html> <head> <meta charset="ISO-8859-1"> <title>Angular ngResource</title> <script src= "https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> <script...

Web Api 2 with two method with the same HTTP verb an angularjs resources

angularjs,rest,asp.net-web-api2,ngresource
I have this controller: public class SeguiAttivazioneController : ApiController { [HttpGet] public IHttpActionResult DoWork1() { ... return Ok(); } [HttpGet] public IHttpActionResult DoWork2() { ... return Ok(); } [HttpGet] //I would like to have a search with GET verb, but I cannot validate my ModelState with dataAnnotation public IHttpActionResult AnotherSearch(string...

How to call my factory service correctly?

javascript,angularjs,ngresource
I am getting the 'is not a function' error when trying to invoke my service. NgResource is already injected. What am I doing wrong? controller.js: app.controller('controllerA', ['$scope', 'CustomizingService', function($scope, CustomizingService) { $scope.cust = CustomizingService.Customizing.squares({numberOf: 2, valid: true}); }]); service.js: (function () { angular.module('ST_CCG').factory('CustomizingService', ['$resource', function ($resource) { //var url =...

Passing Data vs. Separate Request in AngularJS using ngResource

angularjs,angular-resource,ngresource
I'm new to angular and trying to figure out how best to accomplish this. Say you have set up an ngResource factory to get a bunch of widgets . You return those widgets(GET /api/widgets) and display them on the page in a list. Now say you can edit those widgets...

Can't get only the header in AngularJS (v1.3.15) using $resource and method 'HEAD'

angularjs,http-headers,ngresource
In Angular (v1.2.19), I was able to do something like this in a factory : myApp.factory('GetNumber', ['$resource', function($resource) { var get_headers = $resource('some/url', null, { get_number: { method: 'HEAD', transformResponse: function(data, headers) { var count = headers()['x-number']; return count; } } }); return get_headers; } ]); Call it from my...

ngResource and Json API spec

angularjs,ngresource
I'm working with an API that follows the JSON API spec. http://jsonapi.org/ I'm building an app in Ionic using ngResource, and the resource.query() method expects the response to be an array: [ { "id": 1, "foo": "bar" }, { ... } ] But the JSON API spec passes that nested...

Understanding angularJS $resource isArray property

angularjs,ngresource
i'm learning angular's $resource service and in the angular tutorial a custom action is added (query) that has its method set to 'get' and isArray is set to true return $resource('phones/:phoneId.json', {}, { query: {method:'GET', params:{phoneId:'phones'}, isArray:true} }); However, if you look at the docs for $resource the 'query' action...

AngularJs show Error: [$injector:modulerr] in console?

angularjs,ngresource,ngroute
HTML <!DOCTYPE html> <html ng-app="adaniapp"> <head> <link rel="stylesheet" href="css/bootstrap.min.css" /> <link rel="stylesheet" href="css/font-awesome.css" /> <link rel="stylesheet" href="css/style.css" /> </head> <body> <div id="main"> <div ng-view></div> </div> <script src="js/angular.min.js"></script> <script src="js/angular-route.js"></script> <script src="js/angular-resource.min.js"></script> <script...

Cannot bind ngResource to ngOptions

angularjs,ng-options,ngresource
I have a select element, and I want it populated with the result of a call to a resource via ngResource. <select chosen="" required data-ng-model="coolStuffSelected" data-ng-options="stuff for stuff in coolStuff" class="chosen-select input-md"></select> In my Controller I have CoolStuffResource.query(function(result){ $scope.coolStuff = result; console.log(JSON.stringify($scope.coolStuff)); // prints ["foo","bar","gaz","waka"] }); I see the result...

Retrieve associations in AngularJS & Rails using ngResource

ruby-on-rails,angularjs,ruby-on-rails-4,associations,ngresource
I have Record & Category model: class Record < ActiveRecord::Base belongs_to :category end class Category < ActiveRecord::Base has_many :records end The Category model has a name field which should be used for display. I am using ng-repeat to display the records, the 'record.category.name' causes my page to break: <tr ng-repeat="record...

how to wait until promise returns when using $resource

angularjs,angular-services,ngresource
I have a my controller with an activate method which waits for promises to return before going forward. function activate() { var promises = [getNodesGroup(), getNodes()]; common.activateController(promises, controllerId) .then(function () { log('Activated'); }); } Both of the promises had similar approach to get the data and that was using $http...

angularjs $resource and one-to-many relationship

angularjs,ngresource
what is the right way to use ngResource for a complex data model? There are countless one-table examples out there, but little to nothing covering 1:n and m:n relationships. Assuming a simple 'parent' 1->n 'child' relationship, and the entry point is always through parent: is it necessary to create a...

angularjs: show container only after $resource.query result returned

angularjs,ngresource
I started using angularjs in my app and I encountered a problem when I load server results dynamically. I have a resource: var GroupingTagMachines = $resource('/grouping_tags/:grouping_tag_id/machines', { format: 'json' }, { query: { method: 'get', cache: true, isArray: true } }); And I use it when a link is cliked:...

angularjs ngResource success undefined

javascript,angularjs,ngresource
I have an ngResource factory like so: app.service 'Api', ['$resource', ($resource) -> { Student: $resource "/api/v1/students/:id", {id: "@id", option: "@option"}, { 'update': {method: 'PUT'}} ] I have a controller like so: app.controller 'newStudentCtrl', ($scope, $state, Api) -> $scope.addNewStudent = -> student = Api.Student.save( student: $scope.newStudent ) console.log(student.id) $state.go('student.new', { id:...

How to pass dynamic param in angular $resource

javascript,angularjs,ngresource
I want to pass dynamic value of default param in $resource. Please look into the Plunker. Here when I had passed default param in factory as app.factory('myFactory', ["$resource", function($resource) { return $resource('http://google.com', {timeStamp : (new Date()).getTime()}, { query : { method : 'GET', isArray : true, cache : false }...

Unable to hit my local API route in Express

angularjs,node.js,api,express,ngresource
I have a server and client folder, inside my client folder I have 2 Angular apps /website and /dashboard My current routing setup (just for development) going to / will load the website app and views and /dashboard loads the dashboard up: //website api ================================================================== var website = express.Router(); app.use('/',...

IE9 resource returing array of char instead of JSON object

javascript,json,angularjs,internet-explorer-9,ngresource
I'm having a rating system with an API to handle the ratings. On the Get method is the following code: public JToken Get(string vid) { JToken result = null; var status = new { Rating = 100, UserRated = true }; result = JsonConvert.SerializeObject(status); return result; } and in my...

How to return a promise with ngresource post

ajax,angularjs,promise,angular-promise,ngresource
Been trying to figure out how to return a promise with ngresource post. I can do it with $http but cant figure this out. I am getting .then is not defined error. Controller $scope.addLocation = function (model) { var model = $scope.model; var promise = DocumentLocation.save(model); promise.then(function success(model) { console.log(model);...

id not captured by ngRoute

angularjs,ngresource,ngroute
I have a simple Angular routing config with a home page and some user profiles. For some reason when I navigate to /users/user_3, the controller requests the user index route, users.json, instead of users/user_3.json. This is causing the User service to complain: "Error in resource configuration for action get. Expected...

confused between Api Controller and oData Controller to use with angular's ngresource

angularjs,ngresource,asp.net-web-api-odata
i have an angular application that calls web api . it was working all fine with web api controller and ngresource until i required to get count of results. to get just the count of a result i need to use $inlinecount which only seems to be working with oDataController...

Multiple parameters in AngularJS $resource GET

javascript,angularjs,rest,ngresource
'use strict'; angular.module('rmaServices', ['ngResource']) .factory('rmaService', ['$resource', function ($resource) { return $resource( '/RMAServerMav/webresources/com.pako.entity.rma/:id', {}, { delete: { method: 'DELETE', params: {id: '@rmaId'}}, update: { method: 'PUT', params: {id: '@rmaId'}}, //RMAServerMav/webresources/com.pako.entity.rma/0/3 findRange:{method: 'GET', params:{id:'@rmaId'/'@rmaId'}} }); }]); RMAServerMav/webresources/com.pako.entity.rma/0/3 This is correct way to use findRange REST service. This one returns the rmaID...

I want to get the new ID when new record is created using web API and angular resource

angularjs,ngresource
I am using Web API and Angular Resource to manage my application.. When Using the Save method in my controller I want to receive the new saved record ID... My web API method returns the new ID in the response Created Message.. But I am unable to read it... here...