So, here is my problem. I need to be programmatically able to unselect any selected md-button-toggle inside my md-button-toggle-group. The goal is, when the md-button-toggle-group is hidden and then reshow, it shouldn't have any selected md-button-toggle anymore ; currently, it is keeping a track of what was selected before it went hidden. Unfortunately, none of my tries gave a positive result.
I specifically need to use these graphical components, and I can't modify the expected behaviour.
What did I try :
• to bind checked property of md-button-toggleto a boolean and set it programmatically to false / true whenever I need to select / unselect it. Doesn't work.
• to empty md-button-toggle-group selected attribute : I access it by using a ViewChild() on it, then set myViewChild.selected to null. Doesn't work.
• to set directly checked attribute of the button to true / false, accessing it by a ViewChild. Doesn't work either.
• to set ViewChild attribute value to null. Doesn't work.
• same as previous, but then call _updateSelectedButtonToggleFromValue(). Looks like it would have been good, but this is a private method so I can't access it.
Here is my html
<md-button-toggle-group #toggleGroup="mdButtonToggleGroup">
<md-button-toggle value="btnBorderColor">
<md-icon [style.color]=toolbarBorderColor.selectedOption.value>border_color</md-icon>
</md-button-toggle>
<md-button-toggle value="btnDelete" [(checked)]="delChecked" (click)="doAction(actionsList.Delete)" #deleteBtn>
<md-icon>delete</md-icon>
</md-button-toggle>
</md-button-toggle-group>
And my ts
@ViewChild('toggleGroup')
public toggleGroup: MdButtonToggleGroup;
@ViewChild('deleteBtn')
public toggleDelete: MdButtonToggle;
[...]
public doAction(action: ActionsEnum): void {
if (action === ActionsEnum.Delete) {
this.delChecked = false; // doesn't work
this.toggleGroup.value = null;
this.toggleGroup.selected = null;
// this.toggleGroup._updateSelectedButtonToggleFromValue();
this.toggleDelete.checked = false;
}
this.onActionClick.emit(action);
}
I am kinda stuck and any help would be really appreciated.