Ionic 2 beta ,when to import Ionic ,and why set static parameters instead constructor injection


#1

Hi, am currently planning to re write my app in ionic 2
Been facing loads breaking changes ,just gettting the bare version of it run

what does this do

` import {IonicApp, Page, NavController} from ‘ionic-framework/ionic’;

export class LoginPage {
static get parameters() {
return [[NavController], [UserData]];
}`

and why does this give errors

import {Page, NavController, MenuController} from 'ionic-framework/ionic'; export class Page1 { constructor(menu: MenuController) { this.menu = menu; }


#2

btw --> you do not need to make this.menu = menu, because the dependency injection make this per default.

But in angular 2 (do not know much about ionic) you need to say --> okay this is a component (here page) and i use this service:

import {IonicApp, Page, NavController} from 'ionic-framework/ionic';

@Page({
  templateUrl: 'build/pages/hello-ionic/hello-ionic.html'
  provides: [MenuController]
})
export class Page1 {
  constructor(menu: MenuController) {}
}

This works only if the MenuController is an injectable like a service.


#3

what is IonicApp import responsible for , i ask because i want to know where it need (on all pages or main app.js component) also in the ionic conference app , it uses the second code
ALSO is good idea to develop in ionic beta as i really need push pop nav, with ionic 1.x am doing about 3 duplicates for 3 pages making 9 dups , is that good enough reason to rewrite in ionic 2

`
import {IonicApp, Page, NavController} from ‘ionic-framework/ionic’;

export class LoginPage {
static get parameters() {
return [[NavController], [UserData]];

constructor(nav, userData) {
this.nav = nav;

}`


#4

Ok, I’ve scoured the interwebs and cannot find a reasonable explanation of the usage of static get parameters() :

static get parameters(){
    return [Http];
     }

Is it Ionic’s form of DI? Is it still valid in beta2? Or is it ES6 semantics vs TypeScript?

Is it all the same to add the provider and then inject into the constructor?

@Page({
  ...
  providers: [HTTP_PROVIDERS]
  ...
}
export class MyPage {
  constructor(http:HTTP) {
    this.http = http;
  ...

#5

Yep, same issue. Have no idea how this works…
Will be very appreciated for explanation and usage examples