optimistex / ngx-select-ex

Angular based replacement for select boxes
https://optimistex.github.io/ngx-select-ex/
MIT License
111 stars 42 forks source link

Can't clear initial value #140

Closed chrisj-au closed 5 years ago

chrisj-au commented 5 years ago

I am probably not implementing this correctly but when specifying the allow clear, it only works once the initial value has changed. E.g. page loads, can't clear, change the value in the select, then I can clear. Thanks!

<ngx-select [items]="userSearch" [allowClear]="true">

ngOnInit() {
if (this.existingObject) { // Input adobject provided
      this.adsearch.getADObjects(this.existingObject.name)
        .subscribe(r => {
          this.userSearchFG.controls['ctrlUserSearch'].patchValue(r[0]);
          this.userSearch = r;
      });
    }
}
optimistex commented 5 years ago

@chrisjau Have you checked the demo: https://optimistex.github.io/ngx-select-ex/ If the demo does not help you, so make an example to demonstrate the behavior there: https://stackblitz.com/