I am trying to implement on click of a button in mat-select multiple, an option should get unchecked and should be removed from the checked list too.
for removing the selected option I have written my code as below :
mat-select Option:
<mat-form-field class="full-width">
<mat-select class="multiple-location-list-search-wrapper full-width" #mulLoc required placeholder="Locations" multiple>
<mat-option *ngFor="let l of locationsBasedOnPropertyType; let i = index" class="multiple-field-box" [hidden]="tempLocations[i]"
[value]="l">
{{ l.value }}
</mat-option>
</mat-select>
</mat-form-field>
Delete button:
<span (click)="deleteLocation(i, mulLoc);">Delete Location</span>
<p>
<strong>{{mulLoc.value[i].value}}</strong>
</p>
Delete function:
deleteLocation(index, multipleLocation){
multipleLocation.selected[index]._selected = false;
multipleLocation.selected[index]._active = false;
multipleLocation.selected.splice(index,1);
multipleLocation.value.splice(index,1);
}
By Implementing above, I am able to delete option from selected
& value
array but it's not reflecting in Material UI. Location option is not getting unchecked.
Is there any Hack or internal Method to do the same?
Thanks in advance!