My Angular app has a sorting filter using radio buttons via md-radio-group for users to choose how they want data displayed. The radio buttons work fine, but I'm struggling to clear them when the "Restore Defaults" button is clicked.
This is the code for my view:
<filter-option name="Sort"
placeholder="Select Sorting Option"
[usePlaceholder]="!value"
[visible]="sortFilters.enabled">
<filter-label>{{value | capitalize}}</filter-label>
<filter-menu>
<md-radio-group class="mat-radio-label-content">
<md-radio-button value="alphabetical" class="vert-radiobox-list" (click)="onSortClicked(value = 'alphabetical')">
Alphabetical
</md-radio-button>
<md-radio-button value="reverse alphabetical" class="vert-radiobox-list" (click)="onSortClicked(value = 'reverse alphabetical')">
Reverse Alphabetical
</md-radio-button>
<md-radio-button value="numeric ID" class="vert-radiobox-list" (click)="onSortClicked(value = 'numeric ID')">
Numeric ID
</md-radio-button>
</md-radio-group>
<button md-button class="restore-button" (click)="clearSortingFilters()">Restore Defaults</button>
</filter-menu>
</filter-option>
In my component, I initialize the filter like this:
sortFilters =
{
enabled: true,
value: false
};
And here's the function attached to the "Restore Defaults" button:
clearSortingFilters()
{
this.sendSort.emit(this.value = '');
}
The line
this.sendSort.emit(this.value = '')
clears the selected filter label, but I need help clearing the radio button selections in the md-radio-group too.