我想打印容器的索引
我试着写
{{index}}
但它没有用
<ng-template #stepsClone >
<p>Paragraph {{index}} </p>
<input type="button" (click)="removeStep(index)" value="X" >
</ng-template>
export class AddInterviewComponent {
@ViewChild('stepsClone') template;
@ViewChild('stepsContainer', { read: ViewContainerRef }) container;
constructor(private resolver: ComponentFactoryResolver) { }
cloneStep() {
this.container.createEmbeddedView(this.template);
}
removeStep(index: any) {
this.container.remove(this.template[index]);
}
}
答案 0 :(得分:0)
在组件内部声明
index = 'test';
请发布您的components.ts文件
答案 1 :(得分:0)
尝试此操作以显示模板:
<ng-template [ngTemplateOutlet]="template"></ng-template>