2

I would like to refer to the object property source inside collection.find().observe. I am aware that self and this are obviously referring to the wrong scope and wonder how to pass this.source to the function so I can call it at the console.log(...) lines.

Layer = function(collection) {
    this.source = new ol.source.Vector();

    collection.find().observe({
        added: function () {
            console.log(self.source)
            console.log(this.source)
        }
    });
};
Chris
  • 13,100
  • 23
  • 79
  • 162

0 Answers0