Dynamic template in $ionicLoader


#1

Is there a way to dynamically manage the $ionicLoader template?

For example, our necessity is to maintain a “stack” of loaders, meaning the same loader will stay visible until the end of the stack, but updating an eventual loading message.

Anyone?


#2

Not sure what u mean . You want to keep the loader visible and change the text during its visibility ?


#3

exactly, if possible without the need to destroy and recreate a new loader every time.


#4

This is the default loading function.

$scope.show = function () {
                    $ionicLoading.show({
                        template: 'Loading...'
                    });
                };

You can change it to be

$scope.show = function (text) {
$ionicLoading.show({
template: text
});
};

And then call it inside your code with whatever text you want to display.

for example:

$scope.show('Procrastinating...');
$scope.show('Building Awesomness ....');

Whenever the method $scope.hide() is called it will hide it whatever the message is.

Hope this solves it :slight_smile: