Unable to add components at specific index. Below the plunker link for example. PlunkerAddRemoveComponents
Here, I am able to add components at a specific index at the first time only.
export class AddRemoveDynamic {
idx: number = 0;
constructor(private _dcl: DynamicComponentLoader, private _e: ElementRef) { }
add() {
this._dcl.loadIntoLocation(DynamicCmp, this._e, 'location').then((ref) => {
ref.instance._ref = ref;
ref.instance._idx = this.idx++;
});
}
}
My Scenario is:
- Click on Add Component button 3 times. It will create 3 rows continuously.
- Then click on second row Add button, it will create another row.
- And again click on the same button, it will create component next one row
Here, is the problem, I want to create component at every time next to Add button row.