angularjs - Bootstrap 确认模态窗口服务
问题描述
大家好,我有服务可以打开带有问题和 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 ....
> };
解决方案
推荐阅读
- sql - SQL:加入时的级联条件
- c# - 在具有 2 个不同 .SVC 文件的多线程环境中调用 WCF 服务。同时调用两个服务时出错
- vba - 使用 worksheet.function 将工作表公式更改为 VBA 公式
- neo4j - 在同一属性 Neo4j 中匹配具有两个不同值的节点
- cytoscape.js - 根据 cytoscape.js 中的分层边序列获取数据数组
- oracle - 试图将查询中的单个值分配给变量......我做错了什么?
- java - 当文件存在时,文件存在返回假
- 2sxc - 如何在视觉设计师中创建具有多对多关系的连接
- javascript - 1 未捕获的语法错误:JSON 输入意外结束
- javascript - 纯CSS标签卡片翻转