I know you can make use of JavaScript’s class inheritance to set up an “Application Controller” that will serve as the foundation for all of your controllers to build upon. How can you do this without calling import at the top of each file?
Before
import ApplicationController from "./application_controller";
export default class extends ApplicationController {
sayHi () {
super();
console.log("Hello from a Custom controller");
}
}
After
export default class extends ApplicationController {
sayHi () {
super();
console.log("Hello from a Custom controller");
}
}
I was seeing the same error as you and I’ve managed to require ApplicationController everywhere using the following code. I’m using Rails, but I guess you could do this anywhere.