While working on a personal project, I encountered an issue where a function from another class in a separate Java file is not being found, even though it is defined in the respective class.
EventView.js:
displayEvent(event){
this.EventTitle = event.eventName
this.EventDate = event.eventDay + "\n" + event.eventTime
}
EventController.js:
class EventController{
constructor(model, view){
this.model= model
this.view = view
this.onEventChanged(this.model.event_)
this.view.bindChanges(this.handleEditEventName,this.handleEditEventDay,this.handleEditEventTime)
this.model.bindChanges(this.onEventChanged)
}
onEventChanged = event => {
this.view.displayEvent(event)
}
The error message
> EventController.js:13 Uncaught TypeError: this.view.displayEvent is not a function
at EventController.onEventChanged (EventController.js:13)
at new EventController (EventController.js:7)
at EventController.js:31
P.S I am looking for a more efficient way to use classes from other files instead of loading all scripts in the HTML document.