Ng-select: Get previous value on clear

Viewed 60

I'm trying to get the value of an ng-select field before it is cleared.

All change events seem to return only the new value at the moment.

<ng-select [items]="importerFields" [(ngModel)]="selectedConstant[constant.constant_name]" bindLabel="label"
                        [multiple]="constant.allow_match_with_multiple_constants"
                        [closeOnSelect]="!constant.allow_match_with_multiple_constants" appendTo="body"
                        placeholder="{{ ('IMPORTER.FILES_COLUMN' | translate).replace('CONSTANT_NAME', constant.label) }}"
                        (change)="constantChanged(constant, $event)">
                    </ng-select>

Using the above code example, when the X button is pressed to clear the ng-select's contents, the value returned from $event inside the function constantChanged returns undefined.

0 Answers
Related