i create modal modal component and code my modals in modal.component.html file. i want use this modal in my header.component.html file in header component.
related part of my header.component.html is below:
<div style="text-align: center">
<a class="social-account-profile icon-plus"
(click)="onButtonClick()"</a>
</div>
onButtonClick is a method in my header.component.ts like below:
export class HeaderComponent implements OnInit {
constructor(public router: Router, public authService: AuthService,
public appGlobal: AppGlobals, public modal: ModalComponent) {
}
ngOnInit() {
}
onButtonClick() {
this.modal.openModal();
}
}
openModal is below method in my modal.component.ts file :
export class ModalComponent implements OnInit {
@ViewChild('projctModal') projctModal: any;
openModal() {
this.projctModal.show();
}
constructor(private formvalidation: FormValidation) {
}
ngOnInit() {
}
}
and my modal.component.html file is below:
<div mdbModal #projctModal="mdbModal" class="modal fade top " id="projctModal" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel"
aria-hidden="true">
</div>
when i run code i get this error in my chrome console:
ERROR TypeError: Cannot read property 'show' of undefined
how can i fix this ?