Right now I'm trying to do something that requires having a checkbox that allows selecting all checkboxes in a list for some other functionality later. The problem is that I'm not quite sure how to make select all work. I thought I would be able to do so through the controller, but then to use component.find, I might need to set aura:id on all the checkboxes and know them in advance. The problem is that I might not know the id in advance.
The second option I considered was possibly having an boolean attribute and possibly update all checkboxes by setting their value to the boolean attribute (false by default). Doing the update either via controller, helper or maybe event. Unsure of the correct approach in doing a select all with a "master" checkbox in Lightning.
<label class="slds-checkbox"
for="select-all"
onclick="{!c.doSelectAllContacts}">
<input name="checkbox" type="checkbox" id="select-all" />
<span class="slds-checkbox--faux"></span>
<span class="slds-form-element__label slds-assistive-text">select all</span>
</label>
<button onclick="{!c.myArbitaryActionWithAllContactsSelected}">Action</button>
<aura:iteration var="con" items="{!v.contacts}">
<tr>
<td class="slds-row-select">
<label class="slds-checkbox" for="{!'select-row-' + index}">
<input name="{!'select-row-' + index}" type="checkbox" id="{!'select-row-' + index}"/>
<span class="slds-checkbox--faux"></span>
<span class="slds-form-element__label slds-assistive-text">select row {!index}</span>
</label>
</td>
<td>{!con.Name}</td>
</tr>
</aura:iteration>