function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sachin Bhalerao 17Sachin Bhalerao 17 

How value="{!this}" pass information in aura:handler

Dear Team ,

Thank you for your continous support !!!

We are using aura:handler in this way :

 <aura:handler name="init" value="{!this}" action="{!c.doInit}" />

value="{!this}" is used to pass information from component to controller . But i am unable to understand what kind of information it passes and on which location of function it passes the information.

Please describe this in easy way and make me understand how it works :

Thanks & Regards
Sachin Bhalerao
Prabhat Sharma 6Prabhat Sharma 6
Hi Sachin,

Let's try to understand this by taking the component rendering lifecycle as a reference here. 

A component is instantiated, rendered, and rerendered during its lifecycle. Between the first two services i.e. Instantiation and Rendering is where the init handler comes into play. 
  • Instantiation - At this stage, the component is constructed. It is similar to instatnitating any variable with any pre-defined value (if assigned). 
  • init event - An event that get's fired after the construction of component and before rendering of the component. Because the component has not rendered yet, it is required to pass the component instance using the "this" keyword. Setting value="{!this}" marks this as a value event i.e. a component event. You should always use this setting for an init event. To summarize, for an init event
    • name = init (pre-defined)
    • value = this (pre-defined)
    • action = controller action (with or without server call)
  • Rendering - Once the component finishes processing the init event, the component renders with all the values defined in the attributes in the component. 
Hope this helps. 
Deepali KulshresthaDeepali Kulshrestha
Hi Sachin,

I have gone through your question aura handler is used to Invoke action on component initialization:-

1:- Use the init event to initialize a component or fire an event after component construction but before rendering.

2:- If a component is contained in another component or app, the inner component is initialized first.

3:- This registers an init event handler for the component. init is a predefined event sent to every component. After the component is initialized, the doInit action is called in the component's controller. In this sample, the controller action sets an attribute value, but it could do something more interesting, such as firing an event.

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com