Best way to handle timeouts of $http?

I want to show a loading spinner in my modal, and meanwhile let the controller do an $http request to fetch data.
at the moment I show the $ionicLoading, then do some work and broadcast the result when finished.
I want to do it differently. I want to show a spinner in some place in the modal, not blocking all of it, and then either show the results when ready or show a “Try again” button instead of the spinner, if it timed out.
Can anyone help?

did you use $q service to return promise of your request?
https://docs.angularjs.org/api/ng/service/$q

No ,but I managed to add “timeout” to my config, and seems to be doing the job. I think…
is using $q better?

May be you can create some online example with your code ?