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
  • 15,864
  • 23
  • 100
  • 186

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
  • 205,937
  • 32
  • 433
  • 399