I am working on an Angular application using TypeScript and I have the following problem.
Into a TypeScript class I have this method:
findArtistBidsAppliedByCurrentWall(bid):Observable<Bid[]> {
  console.log("findArtistBidsAppliedByCurrentWall() START")
  let data:Array<any> = null;
  return this.db.collection('bids',
      ref=> ref.where("wallId", "==", bid.wallId))
      .get()
      .pipe(
          map(snaps => {
             snaps.forEach(function(doc) {
             console.log("BLA: ", doc.id, " => ", doc.data());
             this.myClassMethod();
             return doc.data;
           });
              return null;
          })
          
          
      )
  }
So as you can see into the previous code I am calling a forEach() method on the snaps object.
This method take a callback funtion as paramether. Into this callback function I am trying to execute another method (myCassMethod()) defined directly into my instance, in this way:
this.myClassMethod();
Doing in this way it isn't work because I am obtaining the following error messate into the console:
ERROR TypeError: this is undefined
    findArtistBidsAppliedByCurrentWall notifications.service.ts:187
    node_modules vendor.js:159712
    node_modules vendor.js:145978
    node_modules vendor.js:145609
    node_modules vendor.js:145609
    node_modules vendor.js:145527
    node_modules vendor.js:145977
    node_modules vendor.js:159711
    findArtistBidsAppliedByCurrentWall notifications.service.ts:184
    RxJS 4
    Angular 6
    RxJS 3
    Angular 16
    RxJS 4
    schedule Angular
    RxJS 4
    Angular 20
    node_modules vendor.js:157356
    node_modules NextJS
    node_modules vendor.js:149711
    node_modules vendor.js:149679
    Ur index.cjs.js:5711
    Us index.cjs.js:11891
    step tslib.es6.js:100
    verb tslib.es6.js:81
    fulfilled tslib.es6.js:71
    Angular 13
It seems that form whthin this callback function it can't see the this as instance reference.
How can I solve this problem and correctly call my myCassMethod() method§?
 
    