+ Start a Discussion
Muhammad umerMuhammad umer 

Getting Input values of Strike Input Component in a Parent Controller

I am using Strike Input component as child componet to capture Input Field as below:
 
<c:strike_input auraId="groupName" value="{!v.group.Name}" type="text" name="Name" label="Group Name" errorMessage="Invalid Group Name"/>

Now in the parent component controller i want to get the value of this input user entered but i am not sure how can i do it. I have registered to an event in the parent component like below:
<aura:handler name="onchange" event="c:strike_evt" action="{!c.strikeInputChanged}" />
And in the parent controller:
strikeInputChanged: function(component, event, helper) {
        var groupObj = component.get("v.groupData");
        groupObj.GroupName =  component.find("inputField").get("v.value");      
        component.set("v.groupData", groupObj);
    },
But component.find("inputField").get("v.value") is returning null. 

Please need help on this.
 
Best Answer chosen by Muhammad umer
NagendraNagendra (Salesforce Developers) 
Hi Umer,

Since strike already defined an on change event:
<!-- strike_input.cmp --> <aura:registerEvent name="onchange" type="c:strike_evt"/>
you can just use it like this:
<c:strike_input onchange="{!c.strikeInputChanged}" value="{!v.group.Name}"/>
And catch the events Element to get its value like this:
strikeInputChanged: function(component, event, helper) { event.getSource().get("v.value"); ... },
Hope this helps.

Kindly mark this as solved if it's resolved so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.

Thanks,
Nagendra