Newer Version Available
Step 4: Create a Nested Component
- Click .
- Enter expenseList in the New Lightning Bundle window. This creates a new component, expenseList.cmp.
-
In expenseList.cmp, enter this code.
Instead of using {!expense.Amount__c}, you’re now using {!v.expense.Amount__c}. This expression accesses the expense object and the amount values on it.
Additionally, href="{!'/' + v.expense.Id}" uses the expense ID to set the link to the detail page of each expense record.
-
In form.cmp, update the aura:iteration tag to use the new nested component, expenseList. Locate the existing aura:iteration tag.
Replace it with an aura:iteration tag that uses the expenseList component.
Notice how the markup is simpler as you’re just passing each expense record to the expenseList component, which handles the display of the expense details.
- Save your changes and reload your browser.
Beyond the Basics
When you create a component, you are providing the definition of that component. When you put the component in another component, you are create a reference to that component. This means that you can add multiple instances of the same component with different attributes. For more information about component attributes, see Component Composition.