I'm trying again to pass parameters to my application. Since RC5, I have to use ngModule. (this solution: Passing asp.net server parameters to Angular 2 app no longer works since RC5)
How to pass parameters to ngModule?
Here's a plunker to illustrate problem: Plunker
index.html:
<script>
System.import('app').then(module => module.main('This is RIGHT'),
console.error.bind(console)
);
</script>
main.ts:
import { browserDynamicPlatform } from '@angular/platform-browser-dynamic';
import { provide } from '@angular/core';
import { AppModule } from './app.module';
export function main(test: string) {
browserDynamicPlatform().bootstrapModule(AppModule, [{ providers: provide('Test', { useValue: test, }) }]);
}
app.module.ts
import { NgModule, provide } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
@NgModule({
imports: [
BrowserModule
],
declarations: [
AppComponent
],
providers: [
provide('Test', { useValue: 'This is WRONG' })
],
bootstrap: [ AppComponent ]
})
export class AppModule {
}