javascript - Using Restangular with the same URL but different files -


i need communicate rest web service via angular , i'm using restangular i'm running difficulty. have use same url & post 2 different files. i'm setting base url in .config in app.js , service.js i'm setting other url via restangularconfigurer. baseurl in config has query string appended it. second url in service not. want baseurl in config , post factory input. below example of code

app.js

'use strict';  angular .module('testapp', [   'nganimate',   'ngcookies',   'ngresource',   'ngroute',   'ngsanitize',   'ngtouch',   'ui.bootstrap',   'nggrid',   'google-maps',   'ngmessages',   'restangular' ]) .config(function (restangularprovider, $routeprovider) {    restangularprovider.setbaseurl('http://dev.domain.com:9005/question-ws.htm?&areacode=215');    $routeprovider     .when('/', {       templateurl: 'views/main.html',       controller: 'mainctrl'     })  }); 

service.js

'use strict';  angular.module('testapp')   .factory('nextrestangular', function($http, $sce, restangular){     return restangular.withconfig(function(restangularconfigurer) {       restangularconfigurer.setbaseurl('http://dev.domain.com:9005/next-question-ws.htm');     });   }); 

controller.js

'use strict';  angular.module('testapp')   .controller('screenctrl', function ($scope, restangular, nextrestangular) {      restangular.all().getlist();      nextrestangular.all().getlist();    }); 

i can't seem restangular , can't post nextrestangular. file structure able support this? going wrong?

restangular service handle rest api restful resources.

the .htm in urls leads me believe response not json. don't believe restangular work if case. recommend looking ngresource or $http. if response json, following should on way.

in example, baseurl should "http://dev.domain.com:9005".

restangularprovider.setbaseurl('http://dev.domain.com:9005'); 

i have not used setrequestsuffix before may allow have .htm.

restangularprovider.setrequestsuffix('.htm'); 

then api calls should this.

restangular.all('next-question-ws').get({areacode: 215}); restangular.all('next-question-ws').post(   // json payload here. }); 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -