4

In Beta I could do this:

export class AppBootstrapper {
  constructor(mySettings: AppSettings) {
    bootstrap(App, 
      [
        provide(AppSettings, {
          useFactory: () => mySettings
        })
      ]
    }
  }
}

Whereby 'mySettings' is runtime data from the server.

How can I do this in the latest RC?

export class AppBootstrapper {
  constructor(mySettings: AppSettings) {
    platform.bootstrapModule(AppModule);
  }
}

I can get it into Bootstrap, but not into app.module.ts

providers: [
  { provide: AppSettings, useFactory: => new AppSettings(??) }
]

,

williamsandonz
  • 14,774
  • 21
  • 91
  • 180

1 Answers1

4

You can try the following:

export class AppBootstrapper {
  constructor(mySettings: AppSettings) {
    browserDynamicPlatform({ provide: AppSettings, useFactory: () => mySettings })
       .bootstrapModule(AppModule);
  }
}

Or just add some method main in your app.module.ts file that will return your AppModule and call this method like

platform.bootstrapModule(main(settings));

See also:

Community
  • 1
  • 1
yurzui
  • 190,482
  • 29
  • 403
  • 383