I am using Angular 5 and I have this:
// app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
appendToContainer() {
// Do the stuff here
// Append PanelComponent into div#container
}
}
Now the app.component.html
// app.component.html
<button (click)="appendToContainer()"></button>
<div id="container"></div>
and finally I have a simple component
// panel.component.html
<div class="panelComponent">
This is a panel Component html
</div>
What I want to do is that everytime the button on app.component.html is click I need a panel.component appended into app.component.html
How can I do this?
*ngFor?appendToContainerand use*ngForto create a panel for each item in the array