Наша команда разрабатывает виджет в ServiceNow и хочет показать символ загрузки в нашей кнопке Отправить. Мы получили его, чтобы показать, но символ загрузки длится в течение нескольких секунд после того, как таблица уже загружена, и мы не уверены, почему. Вот как выглядит наш виджет:
<form class="large-margin-bottom col-xs-offset-3 col-xs-6">
<div class="form-group">
<label for="Name Text">${Full Name}:</label>
<input class="input-lg form-control" type="text" ng-model= "c.data.fullName" placeholder="Enter Employee Name" >
</div>
<button type="submit" ng-click="c.send_fullName();"class="btn btn-primary btn-lg btn-block">
<i ng-if="c.data.loading" class="fa fa-spinner fa-spin m-r-sm"></i>${Search}
</button>
</form>
<div ng-if= "data.showTable == 'hi' && !c.data.loading">
<table class="table table-striped table-bordered">
<caption>List of actions for this Employee</caption>
<thead class="thead-light">
<tr>
<th scope="col">Employee Name</th>
<th scope="col">Occupation</th>
<th scope="col">Location</th>
<th scope="col">Start Date</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in data.json">
<td>{{item.name_employee_full}}</td>
<td>{{item.occ}}</td>
<td>{{item.loc}}</td>
<td>{{item.start}}</td>
</tr>
</tbody>
</table>
Наш клиентский контроллер выглядит следующим образом:
function($scope, $location) {
/* widget controller */
var c = this;
//Name send to server
c.send_fullName = function() {
c.data.loading = true;
c.data.action = "addName";
c.data.loading = false;
c.server.update().then(function(){
c.data.action = undefined;
c.data.fullName= '';
})
}
}
Наш серверный скрипт выглядит так:
(function() {
data.fullName= '';
data.showTable = '';
data.json = [];
if (input){
data.fullName = input.fullName;
var subject_person = fetchHR(data.fullName);
data.json = getEmployeeData(data.fullName);
if (input.action == 'addName'){
data.showTable = "hi" ;
}
}
})();