Does anyone know how to make angular fire an event when the view has changed? Or right when a view is requested and downloaded? I’m trying to add loading animations for when pages change.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Take a look at this thread it looks like the
$httpProvider.responseInterceptorsare a good place to add this type of thing.This fiddle shows a good example on where to add code to start/stop a spinner for ajax requests. This fiddle is similar but actually shows and hides a ‘Loading…’ div.
If you only want to show a spinner when views change you can limit your start/stop code to when
content-typeequalstext/htmlsimilar to what this post shows withapplication/json.Note: in my tests it looks like the
headersGetter()['Content-Type']in thespinnerFunctionis omitted when retrieving my .html files whereas it is populated when making service calls.