Topic: How to define a button that has a selected and unselected state?
I want to include in my toolbar a button that have a distinct 'selected' /'unselected' state The aim is to use the button to show and hide a side panel on the web page
Any suggestions?
Arkadiusz Idzikowski staff answered 5 years ago
You can create a variable and update its value on button click, for example:
<button mdbBtn color="primary (click)="onClick()">Button</button>
Then in your typescript code:
buttonSelected = false;
onClick() {
this.buttonSelected = !this.buttonSelected; // update selected state
if (buttonSelected) {
// do something
} else {
// do something
}
}
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Free
- Premium support: No
- Technology: MDB Angular
- MDB Version: 8.8.1
- Device: PC
- Browser: Chrome
- OS: Windows10
- Provided sample code: No
- Provided link: No