1

How can I pass input values to a component that needs to be bootstrapped in angular2

At the time of bootstrap, how can I pass some value to sampleInput?

@NgModule({
  declarations: [SampleComponent],
  imports     : [],
  exports     : [],
  providers   : [
  ],  bootstrap   : [SampleComponent]
})
export class  WrapperAppModule {

}

and my SampleComponent code is,

@Component({
  selector   : 'app-sample',
  styleUrls: ['./app.sample.css'],
  template: `<div>sample app</div>`,
})
export class SampleComponent {

@Input('sampleInput') sampleInput:string;
}
sudharsan tk
  • 494
  • 6
  • 14
  • Can you please be more specific what exactly you do ? – The Hungry Dictator Dec 23 '16 at 06:47
  • What you need to do ? – anshuVersatile Dec 23 '16 at 07:24
  • You can't really do that. Most probably you want some data from the server to be sent to the client, and there is a workaround to what you need to do, but we need more information as the others comments say so. – Alex Beugnet Dec 23 '16 at 13:43
  • Sorry for coming up late, I want to distribute the same app for different clients,without touching the code much.For example if a client wishes to have default theme as "light" or "dark", I want to bootstrap it and launch the app without touching the code itself. For example in main.ts , I would like to do this platformBrowserDynamic().bootstrapModule(WrapperAppModule.forRoot('light')) .catch(err => console.error(err)); – sudharsan tk Dec 27 '16 at 06:18
  • Think I am toooo late here. But did you find any answer to your question.? – Archit Garg Oct 16 '19 at 05:35

0 Answers0