I have a component that shows up a modal when click a button, using this code:
constructor(
private modalService: BsModalService
) {}
showModal() {
this.bsModalRef = this.modalService.show(AboutComponent);
}
How to close this modal from the AboutComponent.ts since it does not have a reference to bsModalRef
?
AboutComponent.html:
<div class="modal-header">
<h4 class="modal-title pull-left">teste</h4>
<button type="button" class="close pull-right" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<h1>teste</h1>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" (click)="closeModal()">Fechar</button>
</div>
AboutComponent.ts
import { Component, OnInit } from '@angular/core';
import { BsModalService } from 'ngx-bootstrap';
@Component({
selector: 'app-about',
templateUrl: './about.component.html',
styleUrls: ['./about.component.scss']
})
export class AboutComponent implements OnInit {
constructor(private modalService: BsModalService) { }
ngOnInit() {
}
closeModal() {
????????????
}
}