From c74b3f7422f8574d9450ab08b0b5c22984b3dbbd Mon Sep 17 00:00:00 2001 From: Brandy Carney Date: Wed, 1 Jun 2016 17:15:37 -0400 Subject: [PATCH] fix(config): pass custom providers in the bootstrap of the app references #6685 --- src/components/app/test/cordova/index.ts | 26 ++++++++++++++++++++++-- src/config/bootstrap.ts | 9 ++++---- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/components/app/test/cordova/index.ts b/src/components/app/test/cordova/index.ts index 6f47fb56897..682c8bf3295 100644 --- a/src/components/app/test/cordova/index.ts +++ b/src/components/app/test/cordova/index.ts @@ -1,7 +1,26 @@ import {Component} from '@angular/core'; import {ionicBootstrap, NavController, Modal, ViewController} from '../../../../../src'; +import {Injectable} from '@angular/core'; +@Injectable() +export class SomeData { + constructor() {} + + getData() { + return "SomeData"; + } +} + +@Injectable() +export class OtherData { + constructor() {} + + getData() { + return "OtherData"; + } +} + @Component({ template: ` @@ -37,7 +56,10 @@ class Page1 { page2 = Page2; sort: string = 'all'; - constructor(private nav: NavController) {} + constructor(private nav: NavController, private someData: SomeData, private otherData: OtherData) { + console.log("Got some data from", someData.getData()); + console.log("Got some data from", otherData.getData()); + } goToTabs() { this.nav.push(TabsPage); @@ -119,6 +141,6 @@ class E2EApp { root = Page1; } -ionicBootstrap(E2EApp, null, { +ionicBootstrap(E2EApp, [SomeData, OtherData], { statusbarPadding: true }); diff --git a/src/config/bootstrap.ts b/src/config/bootstrap.ts index 7b8f664f64b..25a645b90bc 100644 --- a/src/config/bootstrap.ts +++ b/src/config/bootstrap.ts @@ -56,13 +56,11 @@ export function ionicPostBootstrap(ngComponentRef: ComponentRef): Component return ngComponentRef; } - export function ionicProviders(customProviders?: Array, config?: any): any[] { - // add custom providers to Ionic's dev let directives = IONIC_DIRECTIVES; - if (customProviders) { - directives.push(customProviders); - } + + // add custom providers to Ionic's app + customProviders = isPresent(customProviders) ? customProviders : []; // create an instance of Config if (!(config instanceof Config)) { @@ -109,6 +107,7 @@ export function ionicProviders(customProviders?: Array, config?: any): any[ ROUTER_PROVIDERS, provide(LocationStrategy, {useClass: HashLocationStrategy}), HTTP_PROVIDERS, + customProviders ]; }