question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

clear selected value not working

See original GitHub issue

Hi,

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:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
bostromFredrikcommented, Feb 16, 2019

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?

0reactions
manishjankycommented, Aug 29, 2019

Duplicate of #90

Read more comments on GitHub >

github_iconTop Results From Across the Web

DropDownList.ClearSelection() not working - MSDN - Microsoft
I have some code where I need to update the values in a DropDownList. So I save off the current selected value, try...
Read more >
Reset (Clear) DropDownList selection (selected value) using ...
Here Mudassar Ahmed Khan has explained with an example, how to reset (clear) DropDownList selection (selected value) using JavaScript and jQuery.
Read more >
How do I clear the selected value from a select box using ...
You can use prop method. $("#myid option:selected").prop("selected", false).
Read more >
How to Clear the selected item in DropDownList in Angular ...
You can clear the selected item in the below two different ways. By clicking on the clear icon which is shown in DropDownList...
Read more >
Clear the value (selection) of a combobox, dropdown, input
There is no Clear() method equivalent for combo boxes. How do I clear the selection or value of the input without changing it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found