Angular 2 ngOnInit not called

后端 未结 1 574
盖世英雄少女心
盖世英雄少女心 2020-11-30 12:37

I am building an Angular 2 app with version beta.8.
In this app i have a component which implements OnInit.
In this component i have the function ngOnInit, but the n

相关标签:
1条回答
  • 2020-11-30 12:58

    I guess it's a zone issue.

    Inject NgZone (import from angular2/core

    constructor(private zone:NgZone) {}
    
    this._browser.getStorageValue('api_key', api_key => {
      if (api_key) {
        this.zone.run(() => this._browser.gotoMain());
      }
    })
    
    0 讨论(0)
提交回复
热议问题