How to make $ last for atleast given time


I am developing an ionic app where I load content dynamically on click event. I am using $ before hitting the API and $ionicLoading.hide() after getting the response.

I wish to retain loading atleast for 3 seconds even if data is completely loaded for some undefined reasons without using $timeout. I tried duration in $ but that does’nt help. Is this possible, if so how can I achieve that.

As mentioned in docs you can use duration (in miliseconds). 

This will retain loading until next $ionicLoading.hide() is called.

        template: 'Loading...',
        duration: 3000


As i mentioned in my question I tried duration but as soon as hide() is called after response is loaded it stops rendering loading before 3 seconds


Yeah, because duration is the duration, if you do not call hide… so do not call hide or pass a parameter/set a variable to not hide the loading overlay after a request


Yes it’s supposed to do that. As soon as hide is called it should hide the
loading. You can call hide in a timeout