Selecting a value bind the same value to all ng-select dropdowns
See original GitHub issueHi I am using ng-select in ngFor, thus showing up the more than one ng-select dropdown in UI. But issue is whenever i am trying to select a value for a dropDown, it auto selects the same value for all other dropdowns.
Template:
<div>
<ul class="attrib-list" *ngFor="let car of allCarsModelsInState">
<li>{{car.description}}</li>
<div class="pos">
<ng-select [items]="values" [multiple]="true" [closeOnSelect]="true" placeholder="{{'select' | translate}}" [searchable]="false"
[(ngModel)]="selectedCars" (focus)="getListOfCars(car)" [clearable]="false">
<ng-template ng-multi-label-tmp>
<span>{{selectedCars}}</span>
</ng-template>
</ng-select>
</div>
</ul>
</div>
ts file: values = [‘c1’,‘c2’,‘c3’…] Values for cars will be prepared dynamically whenever i click on a dropdown.
export class Cars{
selectedCars[] = [];
getListOfCars(car){
this.values = carvalues
}
}
Please help Thanks
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
ng select - multiple values - select same values more than ...
This way you will end up with an array of values that are unique, but the user is tricked into believing he is...
Read more >AngularJS: API: select
When an item in the <select> menu is selected, the value of the selected option will be bound to the model identified by...
Read more >Angular ng-select
A function to compare the option values with the selected values. The first argument is a value from an option. The second is...
Read more >ng-select How to programmatically set a value
Connect with: this. optionsSelect = [ { value: '1', label: 'Option 1' }, { value: '2', label: 'Option 2', SELECTED: true }, {...
Read more >Angular Basics: How To Get Value of Selected Dropdown ...
Using ngModel; Using viewChild. Our example app has three components with the same HTML markup, a dropdown with a list of NBA teams,...
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
use stackoverflow for this type of questions
you need to use array indexes or object keys for
ngModel
.