【发布时间】:2016-06-28 08:38:22
【问题描述】:
无法在特定索引处添加组件。例如,在 plunker 链接下方。 PlunkerAddRemoveComponents
在这里,我只能在第一次在特定索引处添加组件。
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++;
});
}
}
我的场景是:
- 单击“添加组件”按钮 3 次。它将创建 3 行 连续不断。
- 然后单击第二行添加按钮,它将创建另一行。
- 再次点击同一个按钮,它将创建下一个组件 行
问题来了,我想每次都在添加按钮行旁边创建组件。
【问题讨论】:
标签: angular angular2-components