I have an Android project created by Cordova witch consume a REST service provided from spring Rest projet on localhost using AngularJs, I try to access to the resource using following code:
'use strict';
angular.module('myService', ['ngResource']).
factory('Demande', function ($http, $resource) {
$http.defaults.useXDomain = true;
return $resource('http:// localhost:8080\:8080/springrestprojet/rest/myobject/:id', {}, {
'save': {method:'PUT',
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin':'*',
'Access-Control-Allow-Methods' : 'POST, GET, OPTIONS, PUT',
'Access-Control-Allow-Headers': 'Origin, Content-Type, Accept',
'Access-Control-Request-Headers': 'X-Requested-With, accept, content-type',
'Accept':'application/x-www-form-urlencoded, multipart/form-data',
'Access-Control-Allow-Credentials': 'true'}},
});
});
I can open to file
C:\Users\User\Mobile\AppClient\platforms\android\assets\www\index.html
and that shows me the correct result.
but when I run application in the emulator that gives me just empty views (no data rest). I changed the ip adress of resource to 10.0.2.2 and to the ip adresse of my machine but that still not working!
I guess there is no communication between my emulator genymotion device and the localhost!
Any proposition please?
Thanks.