大家好,我提供的服务会打开带有问题和2个按钮的引导程序模式窗口(ui-bootstrap)。我要处理的是用户是否单击“确定”或“否”按钮,然后我要删除项目或仅关闭模式窗口。我想在用户可以删除任何项目的每个地方(在不同的控制器中)调用此服务。问题是如何修改此服务?
模板:
> <div class="modal-header">
> <h4>Delete confirmation</h4> </div> <div class="modal-body">
> <p>Item will be permanently deleted! Do you want to continue?</p> </div> <div class="modal-footer">
> <button type="button" class="btn"
> data-ng-click="cancel()">No</button>
> <button class="btn btn-danger"
> data-ng-click="ok();">Ok</button> </div>
服务:
myApp.service('modalService', [
'$modal', function ($modal) {
var self = this;
var modalInstance = null;
self.open = function ($scope, path) {
modalInstance = $modal.open({
templateUrl: path,
scope: $scope
});
};
self.close = function () {
modalInstance.dismiss('close');
};
return self;
}
]);
呼叫服务:
> $scope.deleteTest = function () {
> modalService.open($scope,'js/app/templates/confirmation-modal.html');
// I want to continue to do my delete if Ok button on modal was hit ....
> };