Reputation: 493
I have a following tag:
<tag-input hideForm="true" [onRemoving]="onRemoving"></tag-input>
Where [onRemoving]="onRemoving"
is function is called by attempts to delete value.
It looks like:
public onRemoving(tag: any): Observable<any> {
let del = '';
this.translate.get('confirmation_text').subscribe((res: string) => {
del = res['confirmation_text'];
});
}
Problem is in this code:
this.translate.get('confirmation_text').subscribe()...
I get an error:
TypeError: Cannot read property 'get' of undefined
I think cause is in area of visibility of this
context
Constructor:
constructor(private translate: TranslateService) {
}
Upvotes: 0
Views: 129
Reputation: 3002
change [onRemoving]="onRemoving"
to (onRemoving)="onRemoving($event)"
It might be useful Angular2, ng2-tag-input prevent duplicate value on editable
Upvotes: 3