I'm familar with JQuery but new to AngularJS. One requirement I'm working on is: to display a loading icon and some message above a given HTML element (e.g. DIV) when starts a http request and remove it when http request is done.
In jquery, it's simple, in the ajax handlers, I can use
$('#targetDiv').append(
'<div class="loading">
<img src="loading.gif"/>Loading, please wait...</div>'
);
This code simply operates DOM elements and has nothing to do with models. In AngularJS, how can I do it? Should I use directives?
- Where should the code live? Obviously, the code should not be in the controller files or the view files.
- How can glue the controller code, the view and the loading code together?
Best regards, Zach