Structure of view.ts - split view into multiple controllers

I am wondering whether I can split the MVC model of an ionic view into multiple controllers for one view? My main view seems so feature laden that the view.ts becomes extremely long. Manageable, but annoying. I’m considering to create some parts a component, but wondering if I could instead delegate items into “child” controllers to keep the main view.ts readable.

Is this possible? I can not find any real examples.

Thanks

ps: I’m on Ionic5

Much more idiomatic idea, IMHO.

1 Like

Is it possible to derive from a component? I am importing a third party component and would like to customize it. Can I derive in best OO fashion or should I branch from the original repo? @rapropos

That’s largely a philosophical question, and I’m not currently in the mood for laying out all the reasons why I feel the way I do on this, but the answer to your “can I?” question is “yes”.

That being said, I wouldn’t. I find OO programming overused in general, but that may be PTSD from decades of C++. I especially find JavaScript a very poor language to do OO in, because of lack of integral language support for it - all the OO bits of JavaScript are bolted on as afterthoughts. Finally, I really dislike using inheritance for implementation; I like it much more for interface.

So the idea of using inheritance to extend implementation of a component in an Ionic app is sort of a perfect storm of “nope” for me. What I would do is encapsulate the existing component, if that is possible - wrap a shell around it that incorporates the existing component in its template. That preserves the lines of demarcation of responsibility much more cleanly IMHO.

1 Like