Http request in constructor doesn't change attribute value
<p>I've got a problem with this constructor:</p>

<pre><code> function ApiManager() {
    this.api= new ApiInterface();
    this.apiVersion = -1;

    this.api.getVersion()
        .then(function(version) {
            console.log(version); // "1.0"
            this.apiVersion = version;
            console.log(this.apiVersion); // "1.0"
        }, function(error) {
            console.log("Couldn't find API version.")
        });
}
ApiManager.prototype = {
    getApiVersion: function() {
        return this.apiVersion; // "-1"
    }
};
</code></pre>

<p>I have an object with the attribute apiVersion, which is initialized with the value -1. After that an HTTP request is executed by the ApiInterface and assigns apiVersion the value 1.0. Later I call the function getApiVersion and it returns the old value -1. </p>

<p>I'm new to AngularJS and probably it's a silly rookie mistake, but I don't see what I've got wrong.</p>