component.find()
Find the button component by calling cmp.find("button1") in your client-side controller, where cmp is a reference to the component containing the button.
Syntax: component.find("auraid");
find() returns different types depending on the result.
- If the local ID is unique, find() returns the component.
- If there are multiple components with the same local ID, find() returns an array of the components.
- If there is no matching local ID, find() returns undefined.
component.get()
Returns the value referenced using property syntax.
Syntax: component.get(String key)
For example, cmp.get("v.attr") returns the value of the attr aura:attribute.
Learn Learning Salesforce Lightning Application Development to accelerate your Career with Salesforce!!!
Full Example:
Lightning Component:
<aura:component >
<aura:attribute name="LighningPageProperty" type="String" default="Demo"/>
<aura:handler name="init" value="this" action="{!c.doInit}"/>
<ui:inputText aura:id="inputComponent" class="slds-input" value="{!v.LighningPageProperty}" />
<ui:inputText aura:id="auraid" class="slds-input"/>
</aura:component>
Lightning Controller:
({
doInit : function(component, event, helper) {
component.find("auraid").set("v.value", "Search Example");
component.set("v.LighningPageProperty", "Find Example");
var val = component.get("v.LighningPageProperty");
},
})
No comments:
Post a Comment