I need to get all the values for substitution in ng For, I did, but outputs only the first elements
info.component.html
<div *ngFor="let infoItem of infoItems" >
<div >{{ infoItem.title }}</div>
<ul >
<li ><a href="#" >{{ infoItem.sublinks[].title }}</a></li>
</ul>
</div>
info.items.ts
export const INFO_ITEMS: IInfoItem[] = [
{
title: 'Company',
sublinks: [
{
title: 'About CyberMetals',
},
{
title: 'Careers',
},
],
},
{
title: 'My Account',
sublinks: [
{
title: 'Registration',
},
{
title: 'Account Login',
},
],
},
CodePudding user response:
You need another *ngFor
for the sublinks[]
as it's also an array.
The HMTL should be like this:
<div *ngFor="let infoItem of infoItems" >
<div >{{ infoItem.title }}</div>
<ul >
<div *ngFor="let sublinks of infoItem.sublinks" >
<li >
<a href="#" >{{ sublinks.title }}</a>
</li>
</div>
</ul>
</div>