I have been reading and I can't seem to understand one part of the component – controller – helper – apex combo.
If I have a lightning component that is connected to an apex controller…I am confused how an attribute such as <aura:attribute name="ahg" type="object" />
would know any data. Where is it pulling the data from? What is the value of agh? I can see from a console.log that ahg has a value. I just don't understand how it is set.
Secondly, what is the value of parameters component, event, helper
in the lightning component's controller's function? Is the param component
the object? Is there an easy way to console.log() the event? Right now I get back [Object, Object]. When I: event.toString()
or console.dir()
I get back useless information.
My end goal is to get the value of a custom object's name and hid/display a div dependent on the value. I need to be able to see the values and know what I am playing with so that I can then pass the appropriate data to the apex controller (if needed).
Component
<aura:component controller="CommunityAccountListController" implements="forceCommunity:availableForAllPageTypes" access="global" >
<aura:attribute name="ahg" type="object" />
Controller
({
doInit : function(component, event, helper) {
Best Answer
Ok, I see two questions here:
1) Where are the attribute values coming from
The value of an
aura:attribute
can really come from four placescomponent.set('v.ahg', myVariable)
<c:myComponent ahg="myValue" />
<aura:attribute name="ahg" type="String" value="a String">
More details here. It's hard to apply this to your use case. I don't have enough detail to dig more
2) What are the values of
component, event, helper
The three values contain, in order,
component.find('myComponentId')
)event.getParam('myValue')
)helper.doSomething()
)There are a bazillion more uses for the three classes, but these are basics of what you can do with each. You can start here and read the documentation from there.