gpt4 book ai didi

angular - ng-bootstrap 模态不关闭交叉点击

转载 作者:太空狗 更新时间:2023-10-29 17:42:11 25 4
gpt4 key购买 nike

我正在使用 ng-bootstrap 模式弹出窗口,它不会在单击十字按钮时关闭。

这是 <a>触发弹出窗口的标签 -

<div class="actions padding-zero">
<a href="javascript:void(0);" (click)="openFilter()" class="icon configure-columns-icon">
<span class="control-label">Configure Columns</span>
</a>
</div>

模态 -

<ng-template #filterForm let-modal>
<div class="TitlePanel">
Configure Columns
<button type="button" class="close" aria-label="Close" (click)="modal.dismiss('Cross click')">
X
</button>
</div>
<div class="modal-body">
Body
</div>
</ng-template>

component.ts 文件 -

export class NgbdModalContent {
@Input() name;
constructor(public activeModal: NgbActiveModal) { }
}


@Component({
selector: 'app-modals',
templateUrl: './modals.component.html',
styleUrls: ['./modals.component.scss'],
encapsulation: ViewEncapsulation.None,
})

export class ModalsComponent {

closeResult: string;

constructor(private modalService: NgbModal) { }

// Open default modal
open(content) {
this.modalService.open(content).result.then((result) => {
this.closeResult = `Closed with: ${result}`;
}, (reason) => {
this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
});
}

// This function is used in open
private getDismissReason(reason: any): string {
if (reason === ModalDismissReasons.ESC) {
return 'by pressing ESC';
} else if (reason === ModalDismissReasons.BACKDROP_CLICK) {
return 'by clicking on a backdrop';
} else {
return `with: ${reason}`;
}
}

// Open modal with dark section
openModal(customContent) {
this.modalService.open(customContent, { windowClass: 'dark-modal' });
}

// Open content with dark section
openContent() {
const modalRef = this.modalService.open(NgbdModalContent);
modalRef.componentInstance.name = 'World';
}
}

此外,当我单击关闭按钮时,我在控制台中收到此错误 - “无法读取未定义的属性‘dismiss’”

enter image description here

最佳答案

经过一些研究并做出这些改变后,它奏效了。

<ng-template #filterForm let-d="dismiss">
<div class="TitlePanel">
Configure Columns
<button type="button" class="close" aria-label="Close" (click)="d('Cross click')">
X
</button>
</div>
<div class="modal-body">
Body
</div>
</ng-template>

关于angular - ng-bootstrap 模态不关闭交叉点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52438072/

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