FAQ Database Discussion Community


Rectangular post body empty

angularjs,cordova,ionic,restangular
I'm attempting to post a new user to my servers using rectangular. The post is failing because the post body is always blank. var userData = data.logged_in_user; var userDetails = { id: userData.pk, username: userData.username, pic: userData.profile_pic_url, full_name: userData.full_name }; Restangular.all('users').post(userDetails) .then(function() { console.log('Success') }) .catch(function() { console.log('Error') }); I...

Angular - nested resource without multiple api calls

angularjs,rest,angular-ui-router,restangular
I'm working on an Ionic app that uses Angular UI Router with a Rails api backend. I've got a User model that has many Items. When showing the User page, i'm calling Rails and returning the User along with all it's Items (so I can show them on the user's...

ActionController::RoutingError Rails and Angular

javascript,ruby-on-rails,angularjs,coffeescript,restangular
Every time ProductController is called and Restangular getting data from the rails server. I got this error ActionController::RoutingError (No route matches [GET] "/products.json/6862"): I thought if product.json/:id is the route with rails it will automatically go to show view (show.json.jbuilder). Any idea what did I miss? ProductController.js.coffee controllers = angular.module('controllers')...

AngularJS how do I execute code only after a promise is resolved? (with Restangular)

angularjs,promise,restangular
This might be a nooby question but I still haven't been able to get my head around promises and specifically how to write code with them. (I've read several articles but most of them are abstract and I simply haven't written enough to have a clear picture) I've got an...

Can't use `all()` with `getList()` in Restangular?

javascript,angularjs,api,rest,restangular
I hope to access trips/list_by_user using Restangular.. I found this doesn't work.. Restangular.all('trips').getList('list_by_user') But this works well.. Restangular.one('trips', 'list_by_user').getList() I think all maybe a better way because I want a list instead of an element.. Does anyone have ideas about why getList can't be chained with all? Or is there...

Restangular - Specify custom ID key

javascript,angularjs,restangular,angular-services
In Restangular if I declare a service, and do a PUT/PATCH/POST operation it uses the id of the item by default as a primary key. But what if we want to use a custom key? Like a slug or a number ? // GET to /users Users.getList().then(function(users) { var user...

Error: No more request expected with Karma using Restangular from within a Service

angularjs,restangular,karma-jasmine,httpbackend
I have an AngularJS service and service name is User. I use it for authentication. Inside this service, I have an authenticate() function which uses Restangular to make a REST call to our API. It's perfectly working in my Angular application. I just started using karma so I can including...

Test spec executing before $rootScope.$apply() is done resolving promise

javascript,angularjs,jasmine,restangular
I'm writing angular unit tests using Jasmine with angular-mocks' httpBackend. I've managed to properly mock my backend but some one of my tests has some issues with an http call where a value is set to scope after the request is done (in then()). Controller: $scope.startShift is binded to a...

difference between RestangularProvider and RestangularConfigurer

angularjs,restangular
I wanted to add an interceptor to my module. Here is the intial state: app.config(function ($stateProvider, $urlRouterProvider,RestangularProvider) { RestangularProvider.setBaseUrl('/app/services'); }); I modified with this: app.config(function ($stateProvider, $urlRouterProvider, RestangularProvider, RestangularConfigurer) { RestangularProvider.setBaseUrl('/app/services'); RestangularConfigurer.addFullRequestInterceptor(function (element, operation, route, url, headers, params, httpConfig) { if (operation === 'get'){...

Angularjs/Restangular, how to name file blob for download?

javascript,angularjs,restangular
For some reason this seems easier in IE than Chrome/FF: $scope.download = function() { Restangular.one(myAPI) .withHttpConfig({responseType: 'blob'}).customGET().then(function(response) { //IE10 opens save/open dialog with filename.zip window.navigator.msSaveOrOpenBlob(response, 'filename.zip'); //Chrome/FF downloads a file with random name var url = (window.URL || window.webkitURL).createObjectURL(response); window.location.href = url; }); }; Is there a way to do...

Restangular - getList with parameters sent to server

javascript,angularjs,spring,restangular,spring-restcontroller
I have method on server side: @RequestMapping(method = RequestMethod.GET) public List<UserDTO> getAllUsers(@RequestParam(value = "groupId", required = false) Long groupId, @RequestParam(value = "pagination") Pagination pagination){ // some stuff } And I try to send data from client side with Restangular: function getUsers(filters){ restService.all("users").getList(filters).then(function(users){ $scope.data.users = users; }); } // .... getUsers({groupId:...

How to work with nested data angularjs and rails?

ruby-on-rails,angularjs,restangular
I am working on an rails application to manage and present images to friends and family. In that application you can have Events -> Subevents -> EventImages routes.rb resources :events do resources :subevents do resources :event_images end end The angularjs part/page is starting when a user selects an specific event....

Cannot read property 'then' of undefined - AngularJS

angularjs,restangular
I want to include Asp.Net Identity into my app. But when I want to register a new user, I get an error on javascript side: Cannot read property 'then' of undefined. This is the code in my Controller: When I click the button to register the user, I get in...

Restangular XMLHTTPRequest cannot load, but browser show response

javascript,angularjs,cors,restangular
I'm using Restangular to consume some REST Api that I've built and I'm receiving a XMLHTTPRequest cannot load telling me that my origin is not allowed. But when I look at the network section on browser inspector, the response is there with a 200(Ok) and when I send the request...

Restangular no BaseUrl when do PUT

angularjs,restangular,hateoas
i'm using Restangular and trying to PUT some data but it seems to lose the BaseUrl. In the config function i define the BaseUrl for Restangular and others Restangular fields. Constants.restangularBaseUrl is http://192.168.1.100/api/ RestangularProvider.setBaseUrl(Constants.restangularBaseUrl) .setRestangularFields({ selfLink: '_links.self.href', id: '_id', etag: '_etag' }) .addResponseInterceptor(function(data, operation, what, url, response, deferred){ if (operation...

Restangular call for Elasticsearch data

angularjs,rest,elasticsearch,restangular
I'm trying to use the restangular api to capture specific data from an elasticsearch rest call. I've tried it several different ways (including an attempt to use the addResponseInterceptor). Either I'm just not doing it correctly or I don't understand how/if the data is formatted in a way that can...

Error: [$injector:unpr] Unknown provider: RestangularProvider <- Restangular <- ctrlAG

javascript,angularjs,restangular
I have one app: app.js: angular.module('AngApp', [ 'angularGrid' ]); My own restangular service.js: var app = angular.module('AngApp'); app.factory('restService', ['Restangular', function (Restangular) { // make use of Restangular } ]); and controller.js: var app = angular.module('AngApp'); app.controller('ctrlAG', ['$scope', '$http', '$log', '$mdDialog', 'Restangular',function ($scope,$http, $log, $mdDialog, Restangular) { // make use of...

Restangular getList does not return anything

javascript,angularjs,service,restangular
I am really new with angular and restangular, maybe you can help me, Why does this code work tunariAppApp.controller('ProductListCtrl', function ($scope, Restangular){ Restangular.all('products').getList().then(function(result){ $scope.products= result; }); } ); and this one doesnt???? tunariAppApp.controller('ProductListCtrl', function ($scope, Restangular){ $scope.products = Restangular.all('products').getList(); }); I would like to migrate this code to a service,...

How to inject services to monitor authentication and storage status?

javascript,angularjs,restangular
I'm using Angular.js to build a client side application with Restangular. The problem is, I implemented a digest authentication with a wsse header which i have to generate at each request to my REST Server. I saw that Restangular provide a function : addFullRequestInterceptor(). So now, i'm trying to use...

Restangular response.headers always null or undefined

angularjs,http-headers,restangular
I'm using Restangular on my angularjs app. I'm issuing a request that gives me some response headers I need to retrieve. I'm using RestangularConfigurer.setFullResponse(true) so I can access response.headers. The problem is I'm getting null or undefined for every value I'm trying to retrieve. Here's the code. In the controller:...

Modify restangular service path

angularjs,restangular
Now i am creating one service like that : angular.module('test') .factory('AccountResource', function Account(Restangular) { return Restangular.service('accounts'); }); and now the path is /accounts so i just inject that service into one of my controller .controller('ProfileChangePasswordFormController', function ($scope, AccountResource) { $scope.changePassword = function(){ console.log("change passord send request " ); console.log($scope.password); AccountResource.post("chage_password",$scope.password).then(function()...

Angular directive isolate scope to parent binding undefined

javascript,angularjs,angularjs-directive,restangular
I'm using (the awesome) Restangular and i'm running into something that forces me to use scope.$parent (not awesome), and i don't want to use that. It seems even though my controller is the parent scope to my directive's scope, the = isolated scope binding is evaluated before my parent controller...