From a0251305ead688203047a2908287b6b67483139a Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Fri, 10 Jun 2016 17:35:06 -0700 Subject: [PATCH] doc(CompilerCli): Add a bootstrap example for a compiled application --- modules/@angular/compiler-cli/README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/@angular/compiler-cli/README.md b/modules/@angular/compiler-cli/README.md index daafa136f5..e2114334c1 100644 --- a/modules/@angular/compiler-cli/README.md +++ b/modules/@angular/compiler-cli/README.md @@ -24,7 +24,17 @@ $ ./node_modules/.bin/ngc -p path/to/project In order to write a `bootstrap` that imports the generated code, you should first write your top-level component, and run `ngc` once to produce a generated `.ngfactory.ts` file. Then you can add an import statement in the `bootstrap` allowing you to bootstrap off the -generated code. +generated code: + +```typescript +import {ComponentResolver, ReflectiveInjector, coreBootstrap} from '@angular/core'; +import {BROWSER_APP_PROVIDERS, browserPlatform} from '@angular/platform-browser'; + +import {MyComponentNgFactory} from './mycomponent.ngfactory'; + +const appInjector = ReflectiveInjector.resolveAndCreate(BROWSER_APP_PROVIDERS, browserPlatform().injector); +coreBootstrap(MyComponentNgFactory, appInjector); +``` ## Configuration