Faced weird thing with Dashboard->template

I am using code below (in picture) to show my array (msg.payload) in my template node, but the weird thing I have faced is, it is not showing any arrays when I use "limitTo:msg.len", but when I changed the "msg.len" to any number below 85, it shows my first 85 or any number below than that of arrays from msg.payload!!
for example, if I put "limitTo:86" or "limitTo:msg.len", it wont show anything on my webUI, but once I change it to "limitTo:85", it show the first 85 members of array.
my msg.payload usually have more than 270 arrays of data as picture below and I passed msg.payload.length to msg.len, the last number in picure is my msg.len:


I have been struggling with this weird issue for around 2 days and cannot solve it. I am really tired of searching and found nothing about it. the interesting this is, it was working before!
would you please help me solving the issue?

Thanks.

Do you get the same symptom if you put a number in the limitTo definition rather than via msg.len?

@Colin
Thank you for your replay.
if I put any number below than 85 it works fine and normally, and show me list of array on my web UI. But once I put number more than 85 or "msg.len" to see the whole array, it wont produce any output on my webUI.

I fixed the issue, for my, and other's reference, I solved the issue by adding track by $index:

<table>
  <tr>
    <th align="left"></th> 

  </tr>
  <tr ng-repeat="x in msg.payload track by $index">
    <td style="color:darkgreen;font-weight:bold">{{msg.payload[$index]}}</td>
  </tr>
</table>

seems like the ng-repeat is not smart enough to track the index by itself.

FYI: limitTo doesn't work on objects

limitTo

Overview

Creates a new array or string containing only a specified number of elements. The elements are taken from either the beginning or the end of the source array, string or number, as specified by the value and sign (positive or negative) of limit . Other array-like objects are also supported (e.g. array subclasses, NodeLists, jqLite/jQuery collections etc). If a number is used as input, it is converted to a string.
(from https://docs.angularjs.org/api/ng/filter/limitTo

1 Like

In may case I had the exact same scenario with much shorter array length,on other machine, and it works with "limit to" without any error. that is why I got confused why it is working on another machine and not working on this machine. this ticket has been open more than a year, and since I faced it again, I fixed and put my comment here, to help other facing the same damn thing. by the way, when the problem solved, it is easy to put comment and mentioning the principles!

Sorry, when I looked at your debug, I thought you were passing objects.

Have you opened a console on your browser to see if there are any errors showing up. If it works with a limit of 85 and fails after that, I'd expect it to be a memory issue and some error popping up

Which browsers did you try and on what machine?

Browser: Google Chrome
Machine: RaspberryPi Jessie Lite I believe! (not sure about exact OS name, but it is Linux)
node-red-dashboard version: 2.14.0-beta

I enabled debug log and was no error reported. when I digged more last night (similar issue with bug I reported last year), I found it is only looping once on my array (I printed only $index, it just printed 0)
so when I added "track by $index" and removed "limit to" , it started to loop on the array properly.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.