According to the Sencha Documentation here: https://docs.sencha.com/extjs/7.0.0/modern/Ext.app.Application.html we can automatically load application controllers as needed via the controllers configuration of the Ext.application() method (thus avoiding the need to include many script tags within the html) like so:
Ext.application({
name: 'App',
controllers:['Main']
});
this requires a controller like this:
Ext.define('App.controller.Main', {
//extend: 'Ext.app.ViewController',
extend: 'Ext.app.Controller'
});
And this works. However, the controllers must derive from Ext.app.Controller and can not be Ext.app.ViewController (in which case we receive error because of a missing doInit() controller method). Can anybody explain why is that? And how to instantiate an Ext.app.ViewController using the automatic loading logic?
You are confusing ViewControllers with AppControllers. ViewControllers are the C from MVC while AppControllers kinda global. Those are not specific to any view but application. The lifecycle also different as ViewControllers created for views while AppControllers created for the entire application. In your example you need
Ext.app.Controllerinstead ofViewController, if you wish to useViewControllerit must be attached to e.g. aExt.Component.