Angular: DynamicComponentLoader loadIntoLocation is not working properly in 2.0.0.beta.1

Created on 11 Jan 2016  ·  3Comments  ·  Source: angular/angular

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

It works on version beta.0:
http://plnkr.co/edit/p6w6bBZfkvXIdDabc1vI?p=preview
Its broken on version beta.1:
http://plnkr.co/edit/3Gn9ZuyMHUdlRqEmqVF7?p=preview

Most helpful comment

According to the breaking changes

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

So moving your code to ngOnInit works correctly

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

All 3 comments

According to the breaking changes

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

So moving your code to ngOnInit works correctly

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

@ericmartinezr Thanks.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alxhub picture alxhub  ·  3Comments

Hongbo-Miao picture Hongbo-Miao  ·  3Comments

gugamm picture gugamm  ·  3Comments

pkozlowski-opensource picture pkozlowski-opensource  ·  3Comments

aquinum6 picture aquinum6  ·  3Comments