+ Start a Discussion
brahmaji tammanabrahmaji tammana 

Calling a controller from a button which is in aura:iteration

Can you someone help me to call a controller from aura:iteration tag ?
<aura:iteration items="{!v.contacts}" var="c">
        <a href="{! '/'+c.Id}" >
        <p> {!c.Name} ( {!c.Birthdate} ) </p>    
        </a>
       <h6> {!c.Email}</h6>
        <ui:inputText label="Greetings !!" value="{!v.greeting}" />
        <ui:button label="Post" press="{!c.gsendmail}" />   
        <button type="button" onclick="{!c.gsendmail}" >Send</button>
    </aura:iteration>

I am able to call from outside aura:iteration but i am not able to do the same within aura:iteration. Basically for all the iteration items i need to put one input text and Post button to send an email by taking the input text field value.

Thanks
Brahma
Tanuj TyagiTanuj Tyagi
Hi brahmajit,
Can you share  the Error that you are getting and share the js code of gsendmail method as well.
brahmaji tammanabrahmaji tammana
Hi Tanuj,

I am not getting any error. Basically it is not calling my controller.
But if i write a button outside aura:iteration tag, it works.

Thanks
Brahma