To provide a client to my angular application, here is my code:
app.service('client', function (esFactory) {
        var elasticserver='elasticHost:9200';
        return esFactory({
            host: elasticserver,
            log: 'warning'
        });
    }
);
But my purpose is to provide dynamically the host name and port to this service.
So how to achieve that ?
Thanks
UPADTE
the server name and port are stored in database. so I was trying to get these values through an http call.
below the code.
at line 6 the elasticserver variable contains the concatenation of the servername and port but at line 11 the elasticserver variable is empty.
app.service('client', function (esFactory, $http) {
    var elasticserver = "";
    $http.get("angularAction").success(
            function(data) {
                elasticserver = data['serverName']+":"+data['port'];
                alert("elasticserver : "+elasticserver);
            }).error(function(data, status, headers, config) {
                            // called asynchronously if an error occurs
                            // or server returns response with an error status.
    });
    alert("elasticserver : "+elasticserver);
    return esFactory({
        host: elasticserver,
        log: 'warning'
    });
}
);
 
    