Angular SweetAlert2 Confirmation

    0

    0

    toperbermudez

    This code updates the data for the app.

    Library: angular

    /*update data */
    updateData(data:any) {
      this.global.swal.fire({
        title: '[APP NAME]',
        text: "[MESSAGE]?",
        icon: 'question',
        showCancelButton: true,
        confirmButtonColor: '#3085d6',
        cancelButtonColor: '#d33',
      }).then(async(result) => {
        if (result.isConfirmed) {
          this.loadingEvent(true);
          try {
            await this.service.updateData(data);
            await this.getData();
            this.global.swal.fire(
              '[APPNAME]',
              '[SUCCESS_MESSAGE]',
              'success'
            ) 
          } catch (error) {
            this.loadingEvent(false);
            this.global.errorHandler(error);
          }
        }
      })
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.