Typically you will set a context variable:
this.db = new Db();
var that = this;
this.load = function()
{
console.log(this); // logs the service context correctly
$http.get('get_nodes/').success(function(ajax_data)
{
console.log(that);
console.log(that.db);
that.db.nodes = ajax_data;
});
I know jQuery's $.ajax
has a context
property, not sure if anything like that exists with Angulars $http
, so this is what I've been doing.