How to trim the array if length is > 5
My JSON is:
{
\"name\": \"aaa\"
\"files\": [
{
\"name\": \"A\",
I suppose you want to keep the full array in your logic, and only trim it in your HTML. If this is the case, just use Array.prototype.slice() where you want to display the trimmed list.
I.e.
<div *ngFor="let i of arr.slice(0,5)">
{{i}}
</div>
You can use slice for that.
let trimmed = data.titles.slice(0, 5);