我有以下标记:
<tag-input hideForm="true" [onRemoving]="onRemoving"></tag-input>
通过尝试删除值来调用函数[onRemoving]="onRemoving"
。
看起来像:
public onRemoving(tag: any): Observable<any> {
let del = '';
this.translate.get('confirmation_text').subscribe((res: string) => {
del = res['confirmation_text'];
});
}
问题在于此代码:
this.translate.get('confirmation_text').subscribe()...
我收到错误:
TypeError:无法读取未定义的属性'get'
我认为原因是this
上下文
构造
constructor(private translate: TranslateService) {
}
答案 0 :(得分:3)
将[onRemoving]="onRemoving"
更改为(onRemoving)="onRemoving($event)"
可能有用Angular2, ng2-tag-input prevent duplicate value on editable