0
從下面的代碼中,我想要顯示加載微調框或任何動畫gif,直到myMessage
應顯示在timeout
上點擊Submit
按鈕上。我該如何做到這一點,請讓我知道,並提前致謝!如何在按鈕上單擊顯示微調框或動畫gif,直至顯示消息?
HTML:
<div ng-controller="Controller">
<input type="text" id="inputId" ng-model="enteredMessage"
autofocus/>
<i class="fa fa-spinner fa-spin" style="font-size:24px"></i>
<button type="button" ng-click="myFunction(enteredMessage)">Submit</button>
Entered: {{myMessage}}
</div>
JS:
var myApp = angular.module('myApp',[]);
myApp.controller('Controller',['$scope','$timeout', function ($scope, $timeout) {
$scope.myFunction = function(enteredTextMessage){
$timeout(function() {
//I need to show the spinner for three seconds until my myMessage loading/displaying complete
$scope.myMessage = enteredTextMessage;
}, 3000);
}
}
]);
很高興爲您效勞 –