When the user clicks on the "Search" button, content will load and the button label will change to "Searching" with a spinner shown while the content is loading. Once the content has loaded (Promise resolved), the button label will revert back to "Search" and the button will be enabled again.
Although attempted, the below code consistently shows the spinner even after the content has loaded.
HTML :
<button class="btn btn-xs btn btn-blue" ng-click="show()">
<span><i class="glyphicon glyphicon-off"></i></span> {{buttonLabel}}
</button>
Script :
$scope.buttonLabel = "Search";
$scope.show = function() {
$scope.buttonLabel = "Searching";
$scope.test = TestService.getList( $cookieStore.get('url'),
$rootScope.resourceName+"/students" );
$scope.test.then( function( data ) {
if( data.list ) {
$scope.testData = data.list;
$scope.buttonLabel = "Search";
}
}
}
Updated Fiddle : http://jsfiddle.net/xc6nx235/18/