Ionic -angular failed to update view after click on a button

Discussão em 'Angular' iniciado por Sergio Romero, Abril 17, 2025.

  1. Why after click in a button in the ion-alert component, the view don't get update ? For example if i have a property in my component called sending and a handler for a button of my ion-alert :

    // in my component
    public sending = false;

    constructor(
    public alertCtrl: AlertController,
    ) { }

    async deleteFile() {
    const alert = await this.alertCtrl.create({
    header: 'Deseas eliminar el archivo?',
    message: '',
    buttons: [
    {
    text: 'Eliminar',
    role: 'eliminar',
    cssClass: 'btn-alert',
    handler: () => {
    this.sending = true;
    }
    }
    ]
    });

    await alert.present();
    }

    <!-- in my view -->
    <div> {{ sending }} </div>


    The view don't update unless i call the angular method ** markForCheck () ** inside the handler.

    I am using ionic 4 and angular.

    English isn’t my first language, so please excuse any mistakes

    Continue reading...

Compartilhe esta Página