(I 구문에 대해 궁금 누군가를 위해 타이프 라이터를 사용하고) 나는 어제 내 애플 리케이션에 대한 빠른 스파이크를했고, 이것은 쉽게 할 수있는 방법이다. ui.bootstrap 모달 대화 상자를 사용합니다.
원격 서비스 호출과 같이 오래 실행되는 프로세스를 사용하면 $ emit을 통해 이벤트를 "발생"시킵니다. 이것은 가장 바깥 쪽 범위까지 버블 링됩니다. 다음은 내가 추천 한 선입견 검색 기능의 샘플입니다.
function autoCompleteClientName(searchValue, searchType) {
var self = this;
self.$emit("WorkStarted", "Loading Clients...");
//return promise;
if (searchType === 'name') {
return $scope.clientSearchDataService.getClientsByName(searchValue)
.then(function (response) {
self.$emit("WorkCompleted", "");
return response.results;
}, function(error) {
self.$emit("WorkCompleted", "");
console.warn("Error: " + error);
});
} else if (searchType === 'number') {
return $scope.clientSearchDataService.getClientsByNumber(searchValue)
.then(function (response) {
self.$emit("WorkCompleted", "");;
return response.results;
}, function (error) {
self.$emit("WorkCompleted", "");
console.warn("Error: " + error);
});
}
};
그러면 가장 가까운보기의 컨트롤러 인 ng-view를 호스팅하는 "셸"컨트롤러가 있습니다. 여기
(function() {
'use strict';
// Controller name is handy for logging
var controllerId = 'shellCtrl';
// Define the controller on the module.
// Inject the dependencies.
// Point to the controller definition function.
angular.module('app').controller(controllerId,
['$scope', '$modal', shellCtrl]);
function shellCtrl($scope,$modal) {
// Bindable properties and functions are placed on vm.
$scope.title = 'shellCtrl';
$scope.$on("WorkStarted", function(event, message) {
$scope.modalInstance = $modal.open({ templateUrl: "app/common/busyModal/busyModal.html" });
});
$scope.$on("WorkCompleted", function (event, message) {
$scope.modalInstance.close();
});
}
})();
모달 템플릿이 들어
<div class="modal-dialog">
<div class="modal-content">
<img src="/images/loading.gif"width="55" height="55"/>
<h3>Loading data...</h3>
</div>
<!-- /.modal-content -->
</div><!-- /.modal-dialog -->
당신은 어떤 스타일을 오버라이드 (override) 할 필요가 나타날 것입니다
<style>
.modal
{
display: block;
}
.modal-body:before,
.modal-body:after
{
display: table;
content: " ";
}
.modal-header:before,
.modal-header:after
{
display: table;
content: " ";
}
</style>
당신은 모달
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
에 대한 전체 템플릿을 필요로하는 경우
마일 보관 이것은 약 30 분이 걸리는 스파이크 일뿐입니다. 보다 강력한 솔루션을 위해서는 서비스 제거를 위해 여러 통화를 실행하는 경우 시작 및 완료 된 프로세스 수를 추적 할 수 있어야합니다.