Error : Tried to find bootstrap code, but Specify either statically analyzable bootstrap code or pass in an entryModule to the plugins options.
main.ts
getHttp().get('/assets/config.json').toPromise()
.then((res: Response) => {
let conf = res.json();
platformBrowserDynamic().bootstrapModule(createAppModule(conf));
})
I am using angular-cli. With angular v2.3.1 this code was working fine.
I want to fetch json and pass it to @Ngmodules providers
{ provide: Config, useValue: conf }
If the data you are fetching from config.json
are just about a configuration of an application module and you are trying to create a Config
service to store them, I think the best would be to assign it to the environment
and read it in your Config
service later. The environment
is available in main.ts
, so no hacking (createAppModule
) needed.
import { environment } from './environments/environment';
import { AppModule } from './app/';
getHttp().get('/assets/config.json').toPromise()
.then((res: Response) => {
let conf = res.json();
environment.settings = conf;
platformBrowserDynamic().bootstrapModule(AppModule);
});
You must also declare all new properties of environment
in your src/environments/environment.ts
file.