I have an object as:
test = [
{"obj1": {"time":"8:00","array":[{name: "user1", "language": "En"},{"name": "user4", "language": "Fr"}]}}
{"obj2": {"time":"8:00","array":[{name: "user2", "language": "Fr"},{"name": "user3", "language": "Sp"}]}}
]
My HTML:
<div *ngFor="let obj of test">
<div *ngFor="let item of obj.array">
<p>{{obj.time}}</p>
<p>{{item.name}}</p>
<button (click)="getDetails()">Click</button>
</div>
When the button is clicked, I need to get the value of the "time" and "name". I know how to get the value of time as it is only one per the object. But, I am not sure how to get the values of the nested array. I think it can be done by using "index" approach. But, I cannot make it work.
Desired Output: When I click on the button:
8:00,
user1,
En
let item of obj.arrayis problematic asarrayis nested within a dynamic property. In one element it is nested inobj1and in the next it is nested inobj2. You can make it work, but it would be much cleaner if the data model was consistent.{{ obj | json }}in there, when you run the page, angular will spit out theobjin json, so you can take a look at what you are dealing with.