Angular: DynamicComponentLoader loadIntoLocation์ด 2.0.0.beta.1์—์„œ ์ œ๋Œ€๋กœ ์ž‘๋™ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

์— ๋งŒ๋“  2016๋…„ 01์›” 11์ผ  ยท  3์ฝ”๋ฉ˜ํŠธ  ยท  ์ถœ์ฒ˜: angular/angular

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

๋ฒ„์ „ beta.0์—์„œ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค.
http://plnkr.co/edit/p6w6bBZfkvXIdDabc1vI?p=preview
๋ฒ„์ „ beta.1์—์„œ ๊ณ ์žฅ๋‚ฌ์Šต๋‹ˆ๋‹ค.
http://plnkr.co/edit/3Gn9ZuyMHUdlRqEmqVF7?p=preview

๊ฐ€์žฅ ์œ ์šฉํ•œ ๋Œ“๊ธ€

์ฃผ์š” ๋ณ€๊ฒฝ ์‚ฌํ•ญ์— ๋”ฐ๋ผ

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

๋”ฐ๋ผ์„œ ์ฝ”๋“œ๋ฅผ ngOnInit ํ•˜๋ฉด ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค.

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

๋ชจ๋“  3 ๋Œ“๊ธ€

์ฃผ์š” ๋ณ€๊ฒฝ ์‚ฌํ•ญ์— ๋”ฐ๋ผ

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

๋”ฐ๋ผ์„œ ์ฝ”๋“œ๋ฅผ ngOnInit ํ•˜๋ฉด ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค.

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

@ericmartinezr ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.

์ด ๋ฌธ์ œ๋Š” ํ™œ๋™์ด ์—†์–ด ์ž๋™์œผ๋กœ ์ž ๊ฒผ์Šต๋‹ˆ๋‹ค.
์œ ์‚ฌํ•˜๊ฑฐ๋‚˜ ๊ด€๋ จ๋œ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•˜๋ฉด ์ƒˆ ๋ฌธ์ œ๋ฅผ ์ œ์ถœํ•˜์‹ญ์‹œ์˜ค.

์ž๋™ ๋Œ€ํ™” ์ž ๊ธˆ ์ •์ฑ… ์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณด์„ธ์š”.

_์ด ์ž‘์—…์€ ๋ด‡์— ์˜ํ•ด ์ž๋™์œผ๋กœ ์ˆ˜ํ–‰๋˜์—ˆ์Šต๋‹ˆ๋‹ค._

์ด ํŽ˜์ด์ง€๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๋‚˜์š”?
0 / 5 - 0 ๋“ฑ๊ธ‰