let options= \[{value: 'a', id:1},{value:'b',id:2}\];
let items=\[\];
I will be binding this data to ng select with search in ng-options
<ng-select [items]="options"
bindLabel="value"
bindValue="value"
[multiple]="true"
placeholder="Search for..."
[(ngModel)]="items"
(change)="changeFn($event,false)"
[hideSelected]="true"
>
<ng-template
ng-option-tmp
let-item="item"
let-item$="item$"
let-index="index"
>
<div class="row">
<span class="text-muted" >Task filter: {{ item['value'] }}</span>
</div>
</ng-template>
</ng-select>
on click of a button i wanted to push some dynamic data like
function(){
this.item.push({value: 'c', id:3}\];
}
i wanted to display value c as selected in the ng-select how can i make that possible
i have no idea how to make it work. can anyone help me to make it work.
Thanks in advance.
According to the documentation (Change Detection section),
You should update the array's value for both
optionsanditemsinstead of performing object mutation.Demo @ StackBlitz