How to understand Ionic2 Dependency Injection?

Hello, could someone please point me to a resource detailing the Dependency Injection in Ionic2? Like, when I have:

import {Page, NavController, NavParams} from 'ionic-angular';
// ...
constructor(private nav: NavController, navParams: NavParams) 
// ...

How does Ionic know where to get the NavController and NavParams from? After Googling around, I understand they get created when the app starts and when I put them in the constructor the nearest instance (or in the case of a Singleton, the only instance) to the current component gets injected. Still, it is too much magic for me and I would like to understand how it happens.

All you need to understand is Dependency Injection in Angular 2 - check out the following resources:

1 Like

Thank you! I will look over the provided links.