Angular 2.0 和模态对话框 [英] Angular 2.0 and Modal Dialog
问题描述
我试图找到一些关于如何在 Angular 2.0 中执行确认模式对话框的示例.我一直在使用 Angular 1.0 的 Bootstrap 对话框,但无法在网上找到任何 Angular 2.0 的示例.我还检查了 angular 2.0 文档,但没有运气.
有没有办法在 Angular 2.0 中使用 Bootstrap 对话框?
- Angular 2 及以上
- Bootstrap css(保留动画)
- 没有 JQuery
- 没有 bootstrap.js
- 支持自定义模态内容(就像接受的答案一样)
- 最近增加了对多模态叠加的支持.
`
@Component({选择器:'应用程序组件',模板:`<button type="button" (click)="modal.show()">test</button><app-modal #modal><div class="app-modal-header">标题
<div class="app-modal-body">无论您喜欢什么内容,表单字段,任何内容
<div class="app-modal-footer"><button type="button" class="btn btn-default" (click)="modal.hide()">关闭</button><button type="button" class="btn btn-primary">保存更改</button>
</app-modal>`})导出类 AppComponent {}@成分({选择器:'app-modal',模板:`<div (click)="onContainerClicked($event)" class="modalfade" tabindex="-1" [ngClass]="{'in':visibleAnimate}"[ngStyle]="{'display': visible ? 'block': 'none', 'opacity':visibleAnimate ? 1 : 0}"><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><ng-content select=".app-modal-header"></ng-content>