Default values in multi-select async
See original GitHub issueThis is not a bug but a question I am trying to set default values in multi-select with async data source and it’s not working
my HTML
<ng-select style="padding-top: 10px" [items]="users | async" [virtualScroll]="true" bindLabel="name" bindValue="id" placeholder="إختر موظف" [loading]="usersLoading" (add)="addUser($event)" [multiple]="true" [typeahead]="usersinput$" [(ngModel)]="selectedUser"> </ng-select>
and TS
comp: any;
submitted: boolean;
EditCompanyForm: FormGroup;
errors: any;
logo: any;
uploadLogo: any;
progress:any;
selectedUser:User[];
users:any;
usersinput$ = new Subject<string>();
usersLoading = false;
ngOnInit() {
this.loadusers();
this.getComapny();
}
getComapny() {
const id = +this.route.snapshot.paramMap.get("id");
this.companyService.getCompany(id).subscribe(res => {
this.assignCompany(res);
});
}
assignCompany(data) {
this.comp = data;
let u=this.comp.employees.map(a=>a.user);
//here where I am trying to assign the default values
this.selectedUser= u ;
});
}
Expected behavior I can find the selected users + search the backend to select users
Angular 6 ng-select 2.10.5
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (4 by maintainers)
Top Results From Across the Web
React-select Async Multi-select : How to set default selected ...
Like this: <AsyncSelect isMulti cacheOptions loadOptions={promiseOptions} value={yourArray.map((item) => { return { value: item.value, ...
Read more >Async - React Select
A flexible and beautiful Select Input control for ReactJS with multiselect, autocomplete and ajax support.
Read more >react-multi-select-component - npm
Prop Description Type
labelledBy value for aria‑labelledby string
options options for dropdown
value pre‑selected rows
Read more >Multiselect Element - Laraform
Basic Usage; Searchable; Custom Option; Async Options ... default, array, Value of element when the form is initially loaded or reseted.
Read more >Select - WireUI Docs
How to Customize the async-data ; 6 'api' => route('api.users.index'), ; 7 'method' => 'POST', // default is GET ; 8 'params' =>...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
There is warning in console, if you want to set your model as object you should not use bindValue. Or if you want to use bindValue and object as model then define
compareWith
so ng-select could resolve your value by your predicate.Is this issue solved? because i cannot bind the data for async multiselect