ToggleButton provides a way to select a Boolean value using a button. The ngModel directive is used to define a two-way data binding to a Boolean property. That is, preselection of the toggle button is achieved by enabling the Boolean property. A basic example of ToggleButton usage would be as follows:
<p-toggleButton [(ngModel)]="basic" name="basic"></p-toggleButton>
The following screenshot shows a snapshot result of the basic example:
The ToggleButton also provided customized options such as onLabel, offLabel, onIcon, and offIcon over default labels and icons. The label components associated with the toggle button need to trigger the focus of button while clicking on the label, this can be achieved with the inputId attribute. The customized toggle button with labels, icons, and events would be as follows:
<p-toggleButton [(ngModel)]="customized" name="custom" onLabel="I...