clear selected value not working
See original GitHub issueHi,
I need help with clearing the selected value/option. I have tried all I can think of and all suggestions I can find on google but no luck.
Angular 7.2.0 ngx-select-dropdown 1.0.1 ngx-smart-modal 7.1.1
I have a form (Template driven) inside an ngx-smart-modal and in that form I have three ngx-select-dropdown, one input and one textarea.
I have a ul/li list that populates (ngFor) from an array of objects with properties that I bind to the controls (ngx-select-dropdown, input & textarea) in the form with [(ngModel)] (I have also tried [ngModel] and [value] but it doesn´t work).
So, when I click to edit my first “Entry” in the ul-list the modal (ngx-smart-modal) shows and the controls all have the expected values (from the binded object). When I click close/save on the smart-modal it closes.
Then when I select another Entry in the list the values in the ngx-select-dropdown are still the ones from the last item BUT the input and the textarea have the new objects values as expected.
I have added a “debug button” in the same form to be able to directly clear the values (as in issue #39) but that doesnt work.
I have tried:
- Setting the binded object to empty (object = {} and array=[]) as in issue #39.
- Setting the binded object to object with empty property {“keyword”: “”}
- Setting the selected value on the ngx-select-dropdown to empty string
- Reset the form (form.reset()
Nothing works for the ngx-select-dropdown BUT the input and textarea works as expected.
<div class="form-group"> <label for="existing-report-keyword">Sökord:</label> <ngx-select-dropdown #existingReportKeyword="ngModel" id="existing-report-keyword" name="existing-report-keyword" [(ngModel)]="existingEntryData.keywords" (change)="existingKeywordSelectionChanged($event)" [multiple]="true" [config]="existingKeywordConfig" [options]="systemData.keywords"></ngx-select-dropdown> </div>
The property existingEntryData.keywords is an array of objects like this: keywords":[{“keyword”:“WFALKEMVS018”,“active”:“True”},{“keyword”:“WFALKEMVS018”,“active”:true},{“keyword”:“WFALKEMVS009”,“active”:true}]
Can you please help me?
Best regards, Fredrik
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top GitHub Comments
UPDATE
I have created an isolated app with only a ngx-select-dropdown and two buttons, one for loading data and one for clearing the value. I have tried doing the clear in the same way as in issue #39 and have partially succeded. It clears the selected value but it takes two clicks on the clear button.
Can you please show me the full correct code for clearing the selected value in the dropdown?
Duplicate of #90