kuntal
1
I go through
https://github.com/driftyco/ionic-conference-app/blob/master/app/pages/schedule/schedule.js
but not understand why bellow code written and what is advantage of the code
static get parameters() {
return [[IonicApp], [NavController], [ConferenceData], [UserData]];
}
Yea, i don’t understand at all what that means but… as far as i understand, this:
export class SchedulePage {
static get parameters() {
return [[IonicApp], [NavController], [ConferenceData], [UserData]];
}
constructor(app, nav, confData, user) {
this.app = app;
this.nav = nav;
this.confData = confData;
}
is similar to this (i think):
constructor(app: IonicApp, nav: NavController, confData: ConferenceData, user: UserData) {
this.app = app;
this.nav = nav;
this.confData = confData;
}
I had to use the first method (becouse of errors) before i changed to TypeScript (ionic start “nam” --v2 --ts)
This is how you would inject dependencies in pure ES6:
static get parameters() {
return [[IonicApp], [NavController], [ConferenceData], [UserData]];
}
constructor(app, nav, confData, user) {
// ...
}
As @aluknot mentioned it’s an equivalent of the following TypeScript code:
constructor(app: IonicApp, nav: NavController, confData: ConferenceData, user: UserData) {
// ...
}
Angular 2 Dependency Injection (the guide is currently only for TypeScript though).