It's generally a duplicate of this SO 
<http://stackoverflow.com/questions/38937048/how-to-pass-data-into-angular2-module-when-bootstrapping-it>

The problem is that in RC4 I was loading a data from route, then 
bootstrapping app and passing obtained data into it:

// main.ts
import { bootstrap } from '@angular/platform-browser-dynamic';

function bootstrapApp (userData?) {
  bootstrap(AppComponent, [
    { provide: 'UserData', useValue: userData }
  ])
    .catch(err => console.error(err));
}

// UserService.ts
@Injectable()
export class UserService {
  constructor(
    @Inject('UserData') private apiData: any
  ) {
    console.log('UserService', this.apiData);
  }
}


But the same does not work with rc-5, trying to set it up the same way 
throws an error No provider for UserData!:

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

function bootstrapApp (userData?) {
  platformBrowserDynamic().bootstrapModule(
    AppModule,
    { providers: [
      { provide: 'UserData', useValue: userData }
    ]}
  ).catch(err => console.error(err));
}


What is the right way to do it?

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to