Angular: DynamicComponentLoader loadIntoLocation não está funcionando corretamente em 2.0.0.beta.1

Criado em 11 jan. 2016  ·  3Comentários  ·  Fonte: angular/angular

 Error during instantiation of AppComponent!.
There is no component directive at element [object Object]

Funciona na versão beta.0:
http://plnkr.co/edit/p6w6bBZfkvXIdDabc1vI?p=preview
Está quebrado na versão beta.1:
http://plnkr.co/edit/3Gn9ZuyMHUdlRqEmqVF7?p=preview

Comentários muito úteis

De acordo com as mudanças significativas

Component view is not yet created when component constructor is called. -> use onInit lifecycle callback to access the view of a component

Portanto, mover seu código para ngOnInit funciona corretamente

    ngOnInit() {
      this.dcl.loadIntoLocation(ChildComponent, this.elementRef, 'child');
    }

Todos 3 comentários

De acordo com as mudanças significativas

Component view is not yet created when component constructor is called. -> use onInit lifecycle callback to access the view of a component

Portanto, mover seu código para ngOnInit funciona corretamente

    ngOnInit() {
      this.dcl.loadIntoLocation(ChildComponent, this.elementRef, 'child');
    }

@ericmartinezr Obrigado.

Este problema foi bloqueado automaticamente devido à inatividade.
Registre um novo problema se você estiver encontrando um problema semelhante ou relacionado.

Leia mais sobre nossa política de bloqueio automático de conversas .

_Esta ação foi executada automaticamente por um bot._

Esta página foi útil?
0 / 5 - 0 avaliações