【发布时间】:2018-03-04 18:41:28
【问题描述】:
从下面的代码中,我想显示加载微调器或任何动画 gif,直到单击 timeout 上的 Submit 按钮时应显示 myMessage。我该怎么做,请让我知道并提前感谢!
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);
}
}
]);
【问题讨论】:
标签: javascript jquery angularjs spinner gif