I created a dynamic function and send to an onclick function.
let imagecardnew = new Function('item', 'onclickFunction', 'mainclass', imagecard)
var createdimagecard = imagecardnew(this.cardData[i], this.openModal, this.mainlassName);
document.getElementById('deneme')!.appendChild(createdimagecard)
I am pushing to open modal in onclick function
My modal function:
@ViewChild('modal') private modalComponent!: LargeModalComponent
modalConfig: ModalConfig = {
modalTitle: 'Modal',
dismissButtonLabel: 'string',
closeButtonLabel: 'string',
modalClass: 'leftSideBar',
}
async openModal(item:any) {
console.log('deneme',item)
return await this.modalComponent.open()
}
openModal function is running and I saw a console.log output, but modalComponent.open throws an error:
ERROR Error: Uncaught (in promise): TypeError: Cannot read properties of undefined (reading 'modalComponent')
TypeError: Cannot read properties of undefined (reading 'modalComponent')