how to display toggle icon or toggle button in aura component - Salesforce Globe For You
Example:ToggleIcon.cmp
<aura:component >
<aura:attribute name="checkboxValue" type="boolean" default="false"/>
<lightning:input type="toggle" label="Toggle Button:" aura:id="toggleButton" checked="false" name="toggleButton" onchange="{!c.changeCheckboxValue}"/><br/>
The toggle value is:<b>{!v.checkboxValue}</b>
</aura:component>
ToggleIconController.js
({
changeCheckboxValue : function(component, event, helper) {
// get the toggleButton element and check its value
var togglebuttonValue = component.find("toggleButton").get("v.checked");
component.set("v.checkboxValue",togglebuttonValue);
}
})
TestApp.app
<aura:application extends="force:slds">
<c:ToggleIcon/>
</aura:application>
Output:
No comments:
Post a Comment