I want to apply bootstrap loading spinner in my webpage. When user hits the page it loads the file and displays on the webpage and user can regenerate the file by clicking Refresh button. I want to show the loading spinner as there will be some delay to load the file in the webpage as well as when user clicks on Refresh button which generates and loads the file in webpage.
html code:
<div ng-controller="getFileToShow">
<div><button ng-click="loadData()">Refresh</button>
<div>
<object standby="loading" id="htmlFrame" ng-attr-data="{{fileName}}" type="application/pdf" width="100%" height="100%">asa
<iframe ng-src="{{fileName}}" width="100%" height="100%" style="border: none;">
This browser does not support PDFs. Please download the PDF to view it:
</iframe>
</object>
</div>
</div>
</div>
js code:
app.controller('getFileToShow', function ($scope,MyAppService) {
$scope.getFileToShow = function () {
MyAppService.getFileToShow().then(
function (response) {
$scope.fileName = response;
},
function (errResponse) {
});
}
$scope.getFileToShow();
});
//service call
myAppService.getFileToShow = function(){
var Url = myURL+'/myAppData/getFileToShow.form';
$http.get(repUrl).then(
function (response) {
//logic here
},
);
return deferred.promise;
}
I tried from https://www.w3schools.com/howto/howto_css_loader.asp
css:
.loader {
border: 16px solid #f3f3f3; /* Light grey */
border-top: 16px solid #3498db; /* Blue */
border-radius: 50%;
width: 120px;
height: 120px;
animation: spin 2s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
Could not able to apply the loading spinner in my above mentioned html code. Any advice would be helpful. How to show the loading icon when the page is still loading to show the file on the webpage(my above html code is used to display the file on webpage). Similarly when User clicks on Refresh button again it will take some time to regenerate the file and reload that newly created file to the webpage which is displaying the old file.