Good day!
Actually the whole question in the title, I have a button written in HTML, there is a View and there is a Module with an empty array as the via Controller on click I can add anything to the array module, for example here is my View which returns the number:
export class View { addItem() { let plus = document.querySelector('.plus'); plus.addEventListener('click', () => { let num = document.querySelector('.count').innerHTML; return num; }) } }
Here is my Module with the function addNum, which actually needs to add the number to the array:
export the class Module { constructor() { this.num = []; } addNum(num){ this.num.push(num); } }
And here is Controller:
class Controller { constructor(view, module){ this.view = view; this.module = module; } getNum(){ this.cart.addNum(this.view.addItem()); } }
The problem is that when I call the function getNum controller, it works instantly, I wait for a particular event ?
I hope all clearly explained, thanks!