Why can't access to all object on popover


#1

why can’t access to all object on popover callback function ?

 presentPopover(myEvent,item) {



    let popover = this.popoverCtrl.create(PopoverComponent,{
  cb: function(_data) {
if(_data=='delete'){


      this.showLoader();
      this.agornaApi.deleteProduct(this.token,item.id).then(data => {
        this.products = data;
        console.log(data)
         this.loading.dismiss();
      }, (err) => {
 this.toastCtrl.create({
          message: 'اشکال در برقراری ارتباط با سرور',
          duration: 3000,
          position: 'bottom'
        }).present();



 this.loading.dismiss();
        });



}

ionic return this.showLoader is not a function and agorna api or outher component plugin , etc
but on other function i can access to all object

system info:

Ionic Framework: 3.1.1
Ionic App Scripts: 1.3.6
Angular Core: 4.0.2
Angular Compiler CLI: 4.0.2
Node: 7.4.0
OS Platform: macOS Sierra
Navigator Platform: MacIntel
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36


#2

Never type the word “function” anywhere inside of one. Always use arrow functions or lambdas. This saves you from execution context related bugs like this one.