angular-cn/public/docs/_examples/cb-dependency-injection/ts/app/main.ts

27 lines
880 B
TypeScript

// #docregion
import { bootstrap } from 'angular2/platform/browser';
import { provide } from 'angular2/core';
import { XHRBackend } from 'angular2/http';
import { ROUTER_PROVIDERS } from 'angular2/router';
import { LocationStrategy,
HashLocationStrategy } from 'angular2/platform/common';
import { HeroData } from './hero-data';
import { InMemoryBackendService,
SEED_DATA } from 'a2-in-memory-web-api/core';
import { AppComponent } from './app.component';
// #docregion bootstrap
bootstrap(AppComponent, [
ROUTER_PROVIDERS,
provide(LocationStrategy,
{useClass: HashLocationStrategy}),
provide(XHRBackend, { useClass: InMemoryBackendService }), // in-mem server
provide(SEED_DATA, { useClass: HeroData }) // in-mem server data
]).catch((err: any) => console.error(err));
// #enddocregion bootstrap