javascript - Angularjs promise this references window -


i've made basemodel load function, defined below:

    basemodel.prototype.load = function(id) {                     var deferred = $q.defer();                      var self = this;                     db.getbyid(this.gettablename(), id).then(function(data) {                         deferred.resolve(new basemodel(data)); //self has reference window here                     }, function(err) {                         deferred.reject(null);                     });                  return deferred.promise;             }; 

in child class derives basemodel im calling with:

return basemodel.prototype.load.call(this, id); 

but in 'success' part of promise 'var' self has reference window... possible keep reference object , if so, how? can't find example this.

thanks in advance!

return basemodel.prototype.load.call(this, id); <-- line problem. not sure doing there, seeing, you setting this value using call, @ point of code, points window object.

if child object of basemodel childobj. line can be:

return childobj.load(id); 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -