Because you set the binding to ID: bindValue="ID"
. Remove it and it should work.
Read more about bindings here: https://ng-select.github.io/ng-select#/bindings
Source URL: https://stackblitz.com/run?file=src%2Fbindings-default-example.component.ts
html
<ng-select [items]="defaultBindingsList"
[(ngModel)]="selectedCity">
</ng-select>
ts
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'bindings-default-example',
templateUrl: './bindings-default-example.component.html',
styleUrls: ['./bindings-default-example.component.scss']
})
export class BindingsDefaultExampleComponent implements OnInit {
defaultBindingsList = [
{ value: 1, label: 'Vilnius' },
{ value: 2, label: 'Kaunas' },
{ value: 3, label: 'Pavilnys', disabled: true }
];
selectedCity = null;
ngOnInit() {
this.selectedCity = this.defaultBindingsList[0];
}
}
No comments:
Post a Comment