gpt4 book ai didi

css - 使用组件作为内容自定义 ng-bootstrap 模态

转载 作者:太空宇宙 更新时间:2023-11-04 06:48:41 25 4
gpt4 key购买 nike

我一直在尝试使用作为内容传递的组件来自定义模式。但是,我似乎无法让它发挥作用。它只是显示了一个背景,模态框本身没有显示。看这个 fork 的 stackblitz代码以获取更多详细信息。

基本上我只需要自定义模态框的宽度。在指南中,它传递了内容模板引用,如本 section 中所述。 .但就我而言,我传递的不是 TemplateRef,而是一个组件。

最佳答案

删除 <ng-template let-modal> NgbdModalContent 的 wrapper (及其后半部分)的模板。

@Component({
selector: 'ngbd-modal-content',
template: `
<div class="modal-header">
<h4 class="modal-title">Hi there!</h4>
<button type="button" class="close" aria-label="Close" (click)="activeModal.dismiss('Cross click')">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<p>Hello, {{name}}!</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-dark" (click)="activeModal.close('Close click')">Close</button>
</div>
`
})
export class NgbdModalContent {
@Input() name;

constructor(public activeModal: NgbActiveModal) {}
}

关于css - 使用组件作为内容自定义 ng-bootstrap 模态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53049306/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com