2
无法在特定索引处添加组件。例如在plunker链接下。 PlunkerAddRemoveComponents角度2:动态添加特定/第n个位置的组件
在这里,我只能在第一次在特定索引处添加组件。
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++;
});
}
}
我的方案是:
- 单击Add按钮组件的3倍。它会连续创建3行 。
- 然后点击第二行添加按钮,它会创建另一行。
- ,然后再次单击同一个按钮上,它会创建组件下一 行
这里,是一个问题,我想在接下来的每一次添加按钮行创建组件。
它的工作现在。谢谢你的帮助:):):)。再次感谢Gunter Zochbauer。 – user2932411