passing html template and icons on alert ionic 4

蓝咒 提交于 2021-02-08 10:58:33

问题


I have been trying to achieve something like the above in ionic 4 but it seems like there is no hope for me cos it seems I can only use inputs and not a custom HTML & icons been passed on the alert. any idea on how to achieve this pls

async presentColor() {
    const alert = await this.alertController.create({
      header: "Choose Color",
      inputs: [
        {
          name: "Red",
          type: "checkbox",
          label: "Red",
          value: "Red",
          checked: true
        },

        {
          name: "Black",
          type: "checkbox",
          label: "Black",
          value: "Black"
        },
        {
          name: "purple",
          type: "checkbox",
          label: "Purple",
          value: "Purple"
        }
      ],
      buttons: [
        {
          text: "Cancel",
          role: "cancel",
          cssClass: "secondary",
          handler: (data) => {
            console.log("Confirm Cancel", data);
          }
        },
        {
          text: "Ok",
          handler: () => {
            console.log("Confirm Ok");
          }
        }
      ]
    });

回答1:


The Ionic team has not made alert components easily customizable so icons can be added to the alert component. See issue:

https://github.com/ionic-team/ionic/issues/7874

But you could easily create a modal component and reduce its size to be closer to that of the alert dialog box.




回答2:


Why you want use ion alert. You can use other components like popovers to do that




回答3:


I know this is a bit late, but I just created an npm package to handle adding an angular component into a popup.



来源:https://stackoverflow.com/questions/55132453/passing-html-template-and-icons-on-alert-ionic-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!