Get an AlertController without injection

My first Ionic app, my first Angular 4 app, my first Typescript, so please forgive me if this is a silly question.

I want to access AlertController, but I don’t want it injected by the constructor (if the terminology is correct), because I don’t want my many sub-classes to have to supply it in their call to super().

What do I have to do to instantiate AlertController?

I see the signature

new AlertController(_app: App, config: Config): AlertController

How can I gett an App and Config…? Is there an easier/better way?

TIA
Lee

Dependency injection is intended to replace polymorphism, as a better fit for reactive, web programming. So your post feels very 20th century to me. While Angular does support page inheritance, it’s not a good idea unless you know what you’re doing.

I’d be interested to hear how DI is to replace polymorphism.

I assume Angular supports ‘page’ inheritance because Typecript does. Why do you find it to be a bad idea?

It’s working perfectly, so far… famous last words.

You post looks just like bait to start the OO/functional flame war - itself very 20th century :slight_smile:

Also:

No, Angular didn’t support page inheritance until Angular almost-4. Orthogonal to what Typescript does.

“Orthogonal to what Typescript does.”

I don’t understand - Typescript docs seem to make a lot inheritance, abstract classes, interfaces, and general OO principles. Typescript has no intrinsic knowledge of Ionic ‘pages.’ Why is a page implementing an interface or extending an abstract class so bad?

Javascript was written by one guy, in one week. Most of what Typescript does is an illusion. For example, even if you declare a variable private, other parts of the code can modify it. All variables are public, all the time. The Typescript compiler puts a syntactic gate on you at compile time, that’s all. Similarly, even if you declare a variable to be a constant, any part of the code can modify its contents, at any time. Some Typescript best practices explicitly avoid the use of OO, because writing Typescript like Java can cause you to fall into hard-to-fix errors. Using interfaces instead of classes, using functions instead of constants.

So the quick and dirty answer to your question is that there is no such thing as an abstract class. There’s only something that sort of looks like one.