// var that = this; // no need of this line this.messageSuccess = true; setTimeout(()=>{ // <<<---using ()=> syntax this.messageSuccess = false; }, 3000);