error Uncaught TypeError: this.model.addTodo is not a function

  browser, javascript, opera, typeerror, windows

im doing a js course in YouTube and i get this error "Uncaught TypeError: this.model.addTodo is not a function
", here is my code:

export default class View {
    constructor() {
        this.model = null;
        this.table = document.getElementById('table');
        const btn = document.getElementById('add');    
        btn.onclick = () => this.addTodo('Titulo', 'Desc');        
    }

    setModel(model) {
        this.model = model;
    }

    addTodo(title, description) {
        this.model.addTodo(title, description);
    }
}

Source: Windows Questions

LEAVE A COMMENT