How to connect java restful services using ionic services

Error is

Error: Failed to execute 'open' on 'XMLHttpRequest': Invalid URL
    at Object.farmer.saveFarmer (services.js:132)
    at ChildScope.scope.saveFarmer (FarmerRegister.js:5)
    at ionic.bundle.js:22513
    at callback (ionic.bundle.js:32125)
    at ChildScope.$eval (ionic.bundle.js:24673)
    at ChildScope.$apply (ionic.bundle.js:24772)
    at HTMLFormElement.<anonymous> (ionic.bundle.js:32130)
    at HTMLFormElement.eventHandler (ionic.bundle.js:12098)
    at triggerMouseEvent (ionic.bundle.js:2865)
    at tapClick (ionic.bundle.js:2854)

service code

.factory('FarmerSave',['$http','$q','$rootScope', function(http, $q,rootScope){

	var farmer={};

farmer.saveFarmer = function(farmer){

var http = new XMLHttpRequest();
  var url = "";
  var params = farmer;"POST", url, true);

  //Send the proper header information along with the request
  http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http.setRequestHeader("Content-length", params.length);
  http.setRequestHeader("Connection", "close");

  http.onreadystatechange = function() {//Call a function when the state changes.
  	if(http.readyState == 4 && http.status == 200) {

    return farmer;

Reading the error message it is probably a … wait for it … Invalid URL!

Did you try adding “http://” in front of the URL?

i added http also but same error will displayed in console.

You are injecting $http but not using…

In my factories i inject $http and then :

$["Content-Type"] = "application/x-www-form-urlencoded";
.then(function (response) {
.catch(function(error) {

.factory('FarmerSave',['$http','$q','$rootScope', function(**$**http, $q,**$**rootScope)

Missing $$ (Donald Trump Effect¿¿¿ lol)