1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

How to properly set AlertInput type value in Ionic?

Discussão em 'Angular' iniciado por Gomi, Outubro 16, 2024 às 05:42.

  1. Gomi

    Gomi Guest

    I am using Ionic for my latest project, but I am struggling with Alert.

    I have created one this way:

    const alert = await this.alertController.create({
    header: 'Ordering options',
    inputs: this.order.options.map(option => ({
    name: option.name,
    type: "radio",
    label: option.readable,
    value: option.name,
    checked: (option.name === this.order.selected),
    handler: () => {
    this.order.selected = option.name;
    this.order.apply();
    alert.dismiss();
    },
    }))


    Although the code works, the part of ionic lab compilation output is the following alert:

    [ng] ERROR in src/app/overview/order/order-mobile.component.ts(24,7): error TS2322: Type '{ name: any; type: string; label: any; value: any; checked: boolean; handler: () => void; }[]' is not assignable to type 'AlertInput[]'.
    [ng] Type '{ name: any; type: string; label: any; value: any; checked: boolean; handler: () => void; }' is not assignable to type 'AlertInput'.
    [ng] Types of property 'type' are incompatible.
    [ng] Type 'string' is not assignable to type '"number" | "password" | "time" | "text" | "date" | "email" | "search" | "tel" | "url" | "checkbox" | "radio"'.


    What's the matter?

    Thanks for your help.

    Continue reading...

Compartilhe esta Página