Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic Framework - $ionicLoading: How to display both spinner and label?

I don't see an option to display both spinner and label message! Docs.

Is there a simple way to do this or it must be something that I have to do myself?

Example (it doesn't have to look like this of course): http://www.jqueryscript.net/images/jQuery-Ajax-Loading-Overlay-with-Loading-Text-Spinner-Plugin.jpg

Thanks!

like image 399
SupimpaAllTheWay Avatar asked Oct 27 '15 16:10

SupimpaAllTheWay


People also ask

How do you use an ionic spinner?

The default spinner to use is based on the platform. The default spinner for ios is "lines" , and the default for android is "crescent" . If the platform is not ios or android , the spinner will default to crescent . If the name property is set, then that spinner will be used instead of the platform specific spinner.

How do you center an ion spinner?

Add a class spin and set text align center. Save this answer.

How use Javascript loading in ionic framework?

Using Loading First, we need to inject $ionicLoading in our controller as dependency. After that, we need to call the $ionicLoading. show() method and loading will appear.


2 Answers

You can try this:

$ionicLoading.show({
  template: '<ion-spinner></ion-spinner> <br/> My Label'
});

Not tested, I think it will show up the spinner, but maybe no animation.

like image 66
Nam Pham Avatar answered Sep 22 '22 07:09

Nam Pham


You can load your template:

<script id="loading.html" type="text/ng-template">
    <ion-spinner icon="bubbles"></ion-spinner>
    <p>LOADING...</p>
</script>

and in your code:

$ionicLoading.show({
      templateUrl: 'loading.html'
      // noBackdrop: true
    });

or, as Nam Pham suggested, defined an inline template:

$ionicLoading.show({
      template: '<ion-spinner icon="bubbles"></ion-spinner><p>LOADING...</p>'
      // noBackdrop: true
    });

If you want you can defined a different spinner.

You can see how it works here.

like image 20
LeftyX Avatar answered Sep 23 '22 07:09

LeftyX