How do you set the maximum length of a list with LWC? I understand in Angular you could use "ng-maxLength".

<template iterator:item={records}>
  <!-- List up to ten records -->
  <c-item-card key={item.value.Id} item={item.value}></c-item-card>

There's also item.index but that still isn't helpful if I cannot pass the index into a handler/expression. Any ideas?

1 Answer 1


In LWC, such directives don't exist. You will need to create a separate variable to hold the the shortened list.

  • Thanks for the reply. Right now, I'm fetching the list via fetch request. I wanted to expand the list with a "Load more" button. So, you're saying I can't short the list on the iterator itself?
    – Eric
    Nov 17, 2022 at 14:40
  • @TheWebDev Yeah. I have to figure out why this is broken, but you can see the source for an example pagination table.
    – sfdcfox
    Nov 17, 2022 at 16:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .