是否以及如何从Angular 2+模板中的对象中删除键?
伪代码:
<span
(click)="delete objectName.keyName"> cancel
</span>
答案 0 :(得分:-1)
这是一个StackBlitz
https://stackblitz.com/edit/angular-6h5sob?file=src%2Fapp%2Fapp.component.html
<a (click)="delete()">Delete in component</a>
然后
delete() {
delete this.objectName.keyName
}
在您的模板中
如果我尝试获取(click)=“ delete objectName.keyName”
模板解析错误: 解析器错误:在ng:///AppModule/AppComponent.html@0:12(“] delete objectName.keyName”>删除模板中的[delete objectName.keyName]中的第8列中出现意外的标记'objectName'