【发布时间】:2020-04-14 21:44:56
【问题描述】:
我想显示来自组件的模态。 我有一个使用 ng-bootstrap 创建的模态组件,例如跟随(只是一个主体):
<template id="accept" #content let-c="close" let-d="dismiss">
<div class="modal-body">
<p>Modal body</p>
</div>
</template>
import { Component } from '@angular/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
@Component({
selector: 'my-hello-home-modal',
templateUrl: './hellohome.modal.html'
})
export class HelloHomeModalComponent {
closeResult: string;
constructor(private modal: NgbModal) {}
open(content) {
this.modal.open(content).result.then((result) => {
this.closeResult = `Closed with: ${result}`;
}, (reason) => {
console.log(reason);
});
}
}
我真的希望能够从一个组件中打开这个模态
查看我的 homeComponent
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'my-home',
templateUrl: './home.component.html'
})
export class HomeComponent implements OnInit {
constructor() {
}
timer() {
/** want to open this modal from here . **/
}
}
【问题讨论】:
标签: angular ng-bootstrap