You need to sign in to do that
Don't have an account?
Sagar 12
Difference between component.get() and component.find()
I am a beginner in salesforce lightning and trying to create few components.
Can someone explain to me
1) what is the difference between 'id' and 'aura:id' attribute?
2) when to use component.get() and component.find() ?
Can someone explain to me
1) what is the difference between 'id' and 'aura:id' attribute?
2) when to use component.get() and component.find() ?
All Answers
component.find() :
Retrieve a component by its ID in JavaScript code. component.find() returns different types depending on the result.
Locates a component using the localId. Shorthand: get("asdf"), where "asdf" is the aura:id of the component to look for.
Returns different types depending on the result.
component.get()
Returns the value referenced using property syntax. For example, cmp.get("v.attr") returns the value of the attr aura:attribute.