0

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) {
}
Sachila Ranawaka
  • 39,756
  • 7
  • 56
  • 80
Jessie
  • 373
  • 2
  • 6
  • 17

1 Answers1

3

change [onRemoving]="onRemoving" to (onRemoving)="onRemoving($event)"

It might be useful Angular2, ng2-tag-input prevent duplicate value on editable

Mike Adamenko
  • 2,944
  • 1
  • 15
  • 28