ng-repeat and array indexes - Forum

Forum Navigation
You need to log in to create posts and topics.

ng-repeat and array indexes

Good day! I create elements in the properties of an html container. How do I output certain array indexes, as it works in visual Noscript, but does not work in html. I have attached the code as an example. I tried different options, but to no avail! Thanks

<div ng-repeat="sizes in productCard.itemSizes | limitTo:2">

    <div ng-if="sizes.prices[0].price !== 0">
        <p>от [sizes.prices(0).price] ₽</p>
    </div>

    <div ng-if="sizes.prices[0].price === 0 && sizes.prices[1]">
        <p>от [sizes.prices(1).price] ₽</p>
    </div>
</div>

 

@alexander_loc please attach a simple sample app just showing the problem so we can assist you asap.
Thank you!

Quote from luishp on May 20, 2025, 9:23 am

@alexander_loc please attach a simple sample app just showing the problem so we can assist you asap.
Thank you!

I'm attaching a sample. We create an array through the "Load Array" button, when the "Alert" button is clicked, the jsAlert message [pizzas(1).name] is displayed, but the same value [pizzas(1).name] is not displayed in the Container.

Uploaded files:
  • You need to login to have access to uploads.

@alexander_loc you can't show an Array object element value directly in a Container as you have done.
Please take a look at the Arrays section (filters) in the online help to see how to show elements from simple Arrays.
If you want to show a single value from a complex JSON structure, you must use SetVariable first.

Please check the attached file.

Regards.

Uploaded files:
  • You need to login to have access to uploads.
alexander_loc has reacted to this post.
alexander_loc

@luishp I thought there was some way to make a conclusion in ng-repeat cycles. Okay, I'll use this approach. Thanks for the reply.

@alexander_loc the sample you shared here doesn't have any ng-repeat. I can't understand what you need, sorry.