Ng-Select :- After Removing custom text should not be added in dropdownlist

38 views Asked by At

I am adding a custom text in ng-select.When I am removing this text, It should not be added in dropdown list.


   <ng-select [items]="companies" [addTag]="addTagFn" [hideSelected]="true" multiple="true" bindLabel="name" [(ngModel)]="selectedCompanies">
</ng-select>



.ts file

    selectedCompanies;
    companies: any[] = [];
    companiesNames = ['Uber', 'Microsoft', 'Flexigen'];

    ngOnInit() {
        this.companiesNames.forEach((c, i) => {
            this.companies.push({ id: i, name: c });
        });
    }

    addTagFn(name) {
        return { name: name, tag: true };
    }


enter image description here

enter image description here

enter image description here

enter image description here

You can see in the last screenshot text is added in dropdown after removing I don't want this text in dropdown after removing.could you please help me with simple solution.

0

There are 0 answers