Spinner alert Ionic

一世执手 提交于 2020-01-03 15:38:08

问题


I want show an alert with a spinner in subTitle like:

I tryed, without success:

this.alertCtrl.create({
   title: 'Verificando',
   subTitle: '<ion-spinner name="dots"></ion-spinner> foo bar'
});

Any ideas ?


回答1:


Unfortunately AlertController from Ionic 2 doesn't offer a way by default to embed HTML code inside the title/subtitle attribute. Will this alert be used only when you are loading something? On that case I suggest that you use the LoadingController component, with LoadingController it's possible to insert html embedded code as the content attribute.

For instance, on this case I have created a custom CSS animation on class .sp .sp-slices that I'm inserting on the LoadingController variable named loadingCtrl:

this.loading = this.loadingCtrl.create({
            spinner: 'hide',
            content: '<div class="sp sp-slices"></div>'
          });
this.loading.present();

Using this should give you flexibility enough to adjust the LoadingController component to look exactly like what you need.

Ionic 2 also offers other LoadingController designs that are much closer to the native default look for Android iOS and Windows Phone. It's worthy taking a look at their API documentation: https://ionicframework.com/docs/api/components/loading/LoadingController/



来源:https://stackoverflow.com/questions/45867070/spinner-alert-ionic

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