I'm using ng-select in my Angular project and my entities have Id objects that are objects on their own. (the Id contains multiple values).
So for example as items input you would have a cars array like the following:
let cars = [
{
id: { systemId: null, name: null }
brand: null,
type: null
},
{
id: { systemId: null, name: null }
brand: null,
type: null
}
];
So for a car owner I want to set the carId of the car without binding the whole car object. Currently when I use ng-select it would always select he complete car or only a single value like systemId or name.
I tried using
bindValue='id'
but then it says it cannot bind to an object. So in the end I would like to set owner.carId to a car.id . Currently I'm using ng-select in the following way.
<ng-select name="ownerCarId"
[items]="cars"
[(ngModel)]="owner.carId"
[compareWith]="compareBySystemId"
>
<ng-template ng-label-tmp let-item="item">
{{item.systemId + ' / ' + item.name}}
</ng-template>
<ng-template ng-option-tmp let-item="item" let-index="index" let-search="searchTerm">
{{item.systemId + ' / ' + item.name}}
</ng-template>
</ng-select>
Is there a way to do this?