i was creating a application using typescript poo but when i click to open the dialog box this is not working.
follow the code blocks below:
index.ts:
import Modal from "./Modal.js"
import { Obj } from "./Modal.js"
const button = document.getElementById('add-btn')
const closeButton = document.getElementById('close-btn')
const dialog = document.querySelector('dialog')
const button2 = document.getElementById('add-btn2')
let valores: Array<Obj> = []
if (button && closeButton && dialog && button2) {
const modal = new Modal(dialog, valores)
button.addEventListener('click', modal.openModal)
closeButton.addEventListener('click', modal.closeModal)
button2.addEventListener('click', modal.addValues)
}
Modal.ts:
export default class Modal {
modal;
valores;
constructor(modal: HTMLDialogElement | null, valores: Array<Obj>) {
this.modal = modal
this.valores = valores
}
public openModal(): void {
this.modal?.showModal()