Here is the HTML code I used:
<ng-select
[items]="sensorTypes"
bindLabel="label"
[multiple]="true"
placeholder="Select"
[(ngModel)]="selectedAttributes">
</ng-select>
The TypeScript code I implemented looks like this:
ngOnInit(): void {
this.sensorTypes = [
{ label : "Power", value : "P"},
{ label : "Current", value : "C"},
{ label : "Voltage", value : "V"}
];
this.selectedAttributes = [
{label : "Current", value : "C"},
{label : "Voltage", value : "V"}
]
}
Despite the drop-down list working perfectly, the selectedAttributes
are not selected by default. Upon page refresh, Current and Voltage are not automatically selected even though they are visible options.