Skip to content

Commit

Permalink
fix(config): pass custom providers in the bootstrap of the app
Browse files Browse the repository at this point in the history
references #6685
  • Loading branch information
brandyscarney committed Jun 1, 2016
1 parent 7e4b13d commit c74b3f7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
26 changes: 24 additions & 2 deletions src/components/app/test/cordova/index.ts
Original file line number Diff line number Diff line change
@@ -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: `
<ion-toolbar>
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -119,6 +141,6 @@ class E2EApp {
root = Page1;
}

ionicBootstrap(E2EApp, null, {
ionicBootstrap(E2EApp, [SomeData, OtherData], {
statusbarPadding: true
});
9 changes: 4 additions & 5 deletions src/config/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,11 @@ export function ionicPostBootstrap(ngComponentRef: ComponentRef<any>): Component
return ngComponentRef;
}


export function ionicProviders(customProviders?: Array<any>, 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)) {
Expand Down Expand Up @@ -109,6 +107,7 @@ export function ionicProviders(customProviders?: Array<any>, config?: any): any[
ROUTER_PROVIDERS,
provide(LocationStrategy, {useClass: HashLocationStrategy}),
HTTP_PROVIDERS,
customProviders
];
}

Expand Down

0 comments on commit c74b3f7

Please sign in to comment.