I am working with an array of person objects in Angular 5 and displaying them in HTML using ngFor. The Person objects also contain an array of Role objects.
persons:Array<Person>=[];
Each Role object is structured like this:
export class Role{
id:string
label:string;
}
export class Person{
// many attributes
roles:Array<Person>;
}
Within the HTML, I am using ngFor to iterate through the persons Array within a div tag. My goal is to extract and display a comma-separated string of the role labels for each person.
Here's what I'm trying to achieve:
<div *ngFor='let person of persons'>
<p> {{ person.roles.label.join(',') }} </p>
</div>
Any assistance on this matter would be greatly appreciated. Thank you!