I use the new class syntax for JS. When I press a button, I want to call a method from a class. To archieve this, I set this method static.
class NoteController { // The controller class
constructor() { // Initialization
// ...
}
static CreateNote() { // The method to call - static
// ....
}
}
<!DOCTYPE html>
<html>
<head>
// ....
<script src="NoteController.js"></script> // Link the js file to the html file
</head>
<body>
// ....
<button type="button" id="btnCreateNote" onclick="NoteController.CreateNote()">Create</button> // call the method
</body>
</html>
When I click the button, it says, NoteController is not defined. I really do not get, what is wrong there.
A picture of my project folder:
Maybe this helps.