how to show a spinner using a filter in angularjs? -
i using filter show values in table. values fetching ajax calls , want show spinner while values fetching. wrote:
app.filter("fetchedvalue", function(){ return function(fetchedvalue){ if(angular.isundefined(fetchedvalue)){ return "image";//this spinner }else if(fetchedvalue === null){ return "na"; } else{ return fetchedvalue; } } });
it not working. not sure how spinner when value undefined. know how it?
i think misunderstand filter for. function should return true or false depending if want value given function filtered or not.
see https://docs.angularjs.org/api/ng/filter/filter , angularjs custom filter function
to answer question though, forget filter, , use ng-if
or ng-show
or ng-hide
on <img>
when value undefined.
<img ng-hide="fetchedvalue" src="spinner.gif" />
this assumes fetched value truthy. more robust solution set flag in block of request promise, , ng-hide
based on flag.
Comments
Post a Comment