gmerabishvili / angular-ng-autocomplete

NPM package for Angular: https://www.npmjs.com/package/angular-ng-autocomplete
MIT License
156 stars 88 forks source link

selectedValueRender not working #204

Open patriciadaianaboia opened 1 year ago

patriciadaianaboia commented 1 year ago

I have tried to use it but it's not working. Can you please give some examples?

Thanks

gmerabishvili commented 1 year ago

@patriciadaianaboia Check more clear description here: https://github.com/gmerabishvili/angular-ng-autocomplete/pull/161

patriciadaianaboia commented 1 year ago

I would like to see how to implement it, not just a description. Also are you sure it is working? Has it been tested?

We are not able to use it. We want to remove html tags once a value is selected.

elliotSMK commented 1 year ago

I'm also facing this issue - I'm finding that the selectedValueRender function is being called when the component is initially rendered but not when an item is selected.

The template form code I'm using is this:

<ng-autocomplete
        #ngAutoComplete
        [data]="organisationSuggestions"
        name="organisationAutoSuggest"
        [debounceTime]="200"
        [minQueryLength]="3"
        [required]="true"
        (inputChanged)="onChangeSearch($event)"
        [(ngModel)]="model.organisationId"
        [initialValue]=""
        [placeholder]="placeholder"
        [searchKeyword]="keyword"
        notFoundText="Not found"
        [itemTemplate]="itemTemplate"
        [notFoundTemplate]="notFoundTemplate"
        [selectedValueRender]="selectedValueRender"
      >
      </ng-autocomplete>

My render function is this:

public selectedValueRender: any = (item: any) =>
    item === null ? '' : item.parentName === null ? item.name : item.name + ' - ' + item.parentName;

My keyword and placeholder are set here:

public placeholder: string = 'Enter an organisation name';
public keyword: string = 'name';

Any insights why this isn't triggering the render function would be appreciated, thanks!

filipvercauteren commented 1 year ago

I am facing the same problem. SelectedValueRenderer is not called. Any suggestions ?