I have an array of objects like following:
subgoals: any= [
{'index':'0', 'title': 'Subgoal 1', 'priority': 'Max'},
{'index':'1', 'title': 'Subgoal 2', 'priority': 'Low'},
{'index':'2', 'title': 'Subgoal 3', 'priority': 'Avg'},
{'index':'3', 'title': 'Subgoal 4', 'priority': 'Max'},
]
and two properties:
title:string='';
priority:string='';
I iterate over this array of objects on my template:
<div *ngFor=" let chunk of subgoals | chunks: 1; let j = index; " class="mdl-cell mdl-cell--4-col subgoal-card mdl-card">
<div *ngFor=" let subgoal of chunk | values" >
<div class="mdl-card__title">
<h6>{{subgoal.title}}</h6>
</div>
<div class="mdl-card__actions">
<button class="mdl-button" (click)="openSubgoalForEditing(j)">
View
</button>
</div>
</div>
</div>
<div>{{title}}</div>
<div>{{priority}}</div>
Now depending on the index received in my openSubgoalForEditing(j)
I would like iterate over my subgoals[]
array to get the corresponding object and then set title and priority which I can show in my template back.
How can I do this?