Default selection / Programmatically changing selection
See original GitHub issueI have tried all possible ways to set the default value of select box (single). none worked.
I have tried:-
[active]="{id:'1' , text : 'foo' }"
[active]="[{id:'1' , text : 'foo' }]"
[data]="{id:'1' , text : 'foo' }"
[data]="[{id:'1' , text : 'foo' }]"
Is there a way to change selection Programmatically ?
angular 2.0.0-rc.4 ng2-select 1.0.3
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:15
Top Results From Across the Web
How to programmatically change the selected option in an ...
I need to change the selection that is actually displayed in the select box so I can reset it to "show all" so...
Read more >How can I programmatically set a default select option in for ...
I have a for loop in my code that creates elements in a table using data from the database. Each row has a...
Read more >Programmatically Preselect Dropdown Using Javascript
This page describes how to set the selected item on an HTML dropdown list after the page has been rendered using javascript.
Read more >How do you programmatically deselect an item after a ... - Telerik
In short, the article shows how you can clear the selection of input by changing its Value parameter to the default value for...
Read more >Row Selection - JavaScript Data Grid
suppressRowClickSelection : If true , rows won't be selected when clicked. Use, for example, when you want checkbox selection or your managing selection...
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 Free
Top 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
you can do something like this. Its not a clean solution but it works.
My 5 cents. It was tough! template <ng-select name=“dealers” [active]=“activeDealer” [multiple]=“false” [items]=“dealers”
(data)=“refreshValue($event)”//schould be present in code placeholder=“dealers” > </ng-select>
// delcarations dealers : Array < any > = [] activeDealer:Array <any>=[];
// somewhere in code .(async operation) The funny part is with _temp var.
// receiving AJAX response as responseData let _temp = []; responseData.result .forEach((item, index) => { _temp .push({id: item.id, text: item.title}) }); this.dealers = _temp; this.activeDealer=[this.dealers[1]]