How pass variable from controller to service

i have a var in controller and i need it in service to send in a $http service

pass it as a parameter to a service function, which sends the http request?

Yes, I think the bengtler’s suggestion is the best, but you can use this variable as global using, $rootScope.

Yeah, but i think you should try to avoid using rootScope in services/factories/providers.
The scope/rootScope is introduced for the databinding between controller and view or model view - view model.

greets, bengtler

You can use something like this:

var URL = "http://localhost:8080/arm-web/rest/mobile";

var mod_rest = angular.module('api.rest', []);

mod_rest.factory('ApiRest', function($http){

    function post(service, parameter, callback){
		$http.post(URL + service, parameter)
			.success(function(data, status, headers, config) { 
				setTimeout(function(){
        			callback(data, status, headers, config);
    			}, 1)
			})
			.error(function(data, status, headers, config) { 
				setTimeout(function(){
        			callback(data, status, headers, config);
    			}, 1)
		});
    }

    function get(service, callback) { 

		$http.get(URL + service)
			.success(function(data, status, headers, config) { 
				setTimeout(function(){
        			callback(data, status, headers, config);
    			}, 1)
			})
			.error(function(data, status, headers, config) { 
				setTimeout(function(){
        			callback(data, status, headers, config);
    			}, 1)
		});

    }   

    return {
    	post: post,
    	get: get
    };
    
});