When working in Angular, I encountered a situation where filtering a large amount of data in a table was slowing down the process. To address this issue, I wanted to display a spinner every time a filter operation was in progress.
Here is an example similar to my HTML setup:
<body ng-controller="MainCtrl">
Search: <input ng-model="searchText">
<table id="searchTextResults">
<tr><th>Name</th><th>Phone</th><th>Address</th><th>City</th><th>Zip</th><th>Country</th></tr>
<tr ng-repeat="friend in friends | filter:searchText">
<td>{{friend.name}}</td>
<td>{{friend.phone}}</td>
<td>{{friend.address}}</td>
<td>{{friend.city}}</td>
<td>{{friend.zip}}</td>
<td>{{friend.country}}</td>
</tr>
</table>
<div class='myspinner' > <!-- display only if filtering is occurring -->
The challenge is how to incorporate a spinner whenever the filtering process is happening.
CSS for spinner div:
.myspinner {
position: absolute;
left: 45%;
top: 45%;
height:50px;
width:50px;
margin:0px auto;
position: absolute;
-webkit-animation: rotation .6s infinite linear;
-moz-animation: rotation .6s infinite linear;
-o-animation: rotation .6s infinite linear;
animation: rotation .6s infinite linear;
border-left:6px solid rgba(0,170,240,.25);
border-left: 6px solid rgba(0,170,240,.25);
border-right: 6px solid rgba(0,170,240,.25);
border-bottom: 6px solid rgba(0,170,240,.25);
border-top: 6px solid rgba(0,170,240,.6);
border-radius:100%;
}
Link to Plunkr: http://plnkr.co/edit/NcbPPcxL1rk0ZBKpbqZG?p=preview