17.10.2018 Views

Angular

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

}<br />

}<br />

app.component.ts<br />

private elements: Array = [];<br />

...<br />

addComponent(widget: string ): void{<br />

let component = this.dynamicComponent.addComponent(this.WidgetClasses[widget]);<br />

let view: ViewRef = this.dynamicComponent.container.detach(0);<br />

this.elements.push({view,component});<br />

}<br />

this.dynamicComponent.resetContainer();<br />

app.component.html<br />

<br />

<br />

<br />

https://plnkr.co/edit/JHpIHR43SvJd0OxJVMfV?p=preview<br />

GoalKicker.com – <strong>Angular</strong> 2 Notes for Professionals 57

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!