Open ahmadkhalaf1 opened 6 years ago
Try to store the array of objects in a variable (for example userItems
).
Then you can do that:
userItems.find(user => user.id === userId);
And... You can try to use that fork: https://github.com/optimistex/ng2-select-ex There is returning just ID. Your case may be looked like this:
<ngx-select [items]="userItems"
[ngModel]="selectedUserId" (ngModelChange)="userChange($event)">
</ngx-select>
export class SomeComponent {
public selectedUserId: any[] = [];
public userChange(userId: string) {
const user = selectedUserId.find(item => item.id === userId);
console.log('user data', user);
}
}
Hello i am passing this object to the ng-select items
but when i select from the list and go to select function i only get Text and id , i need to get the extra data like nickName , status , userId and so on ? any idea how?