Angular 2 - 组件启动后的事件

Angular 2 - Event after Component is bootstrapped

我遇到了问题。我想要一个全球服务。我发现了这个:。 它有效,但我想在初始化我的组件后 引导我的组件后调用的事件。

有人知道这个活动吗?

莱罗

更新

是的,我想这样做:

import {GlobalService} from './GlobalService';
import {Component, provide, Injector, ComponentRef} from 'angular2/core';
import {bootstrap}        from 'angular2/platform/browser';
import {HTTP_PROVIDERS} from 'angular2/http';
import {appInjector} from './app.injector';
import {RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS,
    LocationStrategy, HashLocationStrategy} from 'angular2/router';
import {AppComponent}     from './app.component';

bootstrap(AppComponent, [
    ROUTER_PROVIDERS,
    provide(LocationStrategy, { useClass: HashLocationStrategy }),
    HTTP_PROVIDERS,
    GlobalService
]).then((appRef: ComponentRef) => {

    var injector = appInjector(appRef.injector);
    var appComp: AppComponent = injector.get(AppComponent);

    appComp.init();
});

但是我得到两个错误:

Unhandled Promise rejection: appComp.init is not a function ; Zone: ; Task: Promise.then ; Value: TypeError: appComp.init is not a function

Error: Uncaught (in promise): TypeError: appComp.init is not a function

bootstrap函数return一个承诺。引导组件时调用此级别提供的回调:

bootstrap(AppComponent).then((compRef:ComponentRef) => {
  // Do something after the component is bootstrapped
  var comp = compRef.instance;
  comp.init();
});