角度2模态窗口/通过服务对话

时间:2016-11-10 12:51:10

标签: angular

我想使用bootstrap标记和css创建自己的模态窗口。我看过像ng2-bootstrap这样的现有项目,但不喜欢我必须将模态html放在模板中 - 我更喜欢它是一个有open()方法返回promise的服务。这就是ng1的angular-ui-bootstrap的工作原理,并希望保留它。不幸的是,ng2版本不支持bootstrap 3。

我可以用什么角度类/ api来实现这个目标?我想创建一个具有动态添加/删除dom节点的open方法的服务。

2 个答案:

答案 0 :(得分:0)

angular-ui-bootstrap的Angular 2版本位于https://ng-bootstrap.github.io,而 具有模态服务,可以打开模板组件:{{3 }}

答案 1 :(得分:0)

考虑这个解决方案:

https://stackoverflow.com/a/45494297/4572425

例如:

alertOK:

this.alertCtmService.alertOK("This is an alert!").subscribe(function (resp) {
    console.log("alertCtmService.alertOK.subscribe: resp=" + resp.ok);
    this.saveData();
}.bind(this) );

alertConfirm:

this.alertCtmService.alertConfirm("Save changes???").subscribe(function (resp) {
    console.log("alertCtmService.alertOK.subscribe: resp=" + resp.ok);
    this.saveData();
}.bind(this) );