This.on not a function

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  constructor(public navCtrl: NavController) {
   
  }

 public off()
  {
        setTimeout(function(){ this.on(); }, 3000);
  }
  public on()
  {
         alert('test');
  }
}

Dont use function but fat arrow ()=>{}

1 Like

Try this @pasupathi03

  off()
  {
        setTimeout( () => {  this.on() }, 1000);
  } 
  on()
  {
         alert('test');
  }
1 Like

It’s working thank you for your solution.

1 Like

Thank you for your replay.

You are welcome

For now remember: never use function in Ionic projects. Only fat arrow is needed and keeping you free from distraction.

Tom