Getting the last element from a JSON array in a Handlebars template

后端 未结 2 1644
难免孤独
难免孤独 2021-01-12 19:23

So, I found that array elements can be accessed in Handlebars using:

{{myArray.2.nestedObject}} and {{myArray.0.nestedObject}}

..to get the

2条回答
  •  灰色年华
    2021-01-12 19:43

    The above piece of code works fine in all the cases. But if the array passed if a null array, possibility of the handlebar function throwing error is there. Instead perform a null check and then return the value accordingly.

提交回复
热议问题