Reputation: 1779
I have an Angular2 component to display the list of speakers in some data. When I put the following code in my xyz.component.html
, it displays the list as comma separated strings. How can I display each one in a different line -- essentially put a line break after every one.
<div *ngIf="data.speakers">
<span class="attr-key">Speakers:</span><br>
<span class="attr-value">{{data.speakers}}</span>
</div>
data
is what comes due to binding. It has an element called speakers that is defined as string[]
.
Upvotes: 0
Views: 1742
Reputation: 222572
You need to use ngFor
to loop over data and display it
<ul>
<li *ngFor="let speaker of data.speakers">
{{ speaker}}
</li>
</ul>
Upvotes: 3