Accessing specific array element in an Angular2 Template
Work around, use ngIf check the length. elements? means if elements is null, don't read the length property.
<div *ngIf="elements?.length">
{{elements[0].name}}
</div>
2020 Edit :
{{elements?.[0].name}}
is the new way for the null check
Original answer : {{elements[0].name}}
should just work. If you load elements
async (from a server or similar) then Angular fails when it tries to update the binding before the response from the server arrived (which is usually the case). You should get an error message in the browser console though.
Try instead
{{elements && elements[0].name}}