ng-repeat length returning 'undefined'

2,108 views
Skip to first unread message

rossl...@gmail.com

unread,
Jul 13, 2012, 7:38:30 PM7/13/12
to ang...@googlegroups.com
Hi all,

I'm new to Angular (and JS MVC in general) so this is probably going to be a dumb question:


All of the other bindings are working great, it's {{table.seats.length}} that I can't seem to get working. Is there a problem with my data structure? Or is it not possible to grab the length.

Sorry if I'm missing something, hopefully someone can point me in the right direction.

I basically need to output the total number of "seat" objects that each "table" has each time it iterates over the "tables" object...

Thank you.

Pawel Kozlowski

unread,
Jul 14, 2012, 2:17:31 AM7/14/12
to ang...@googlegroups.com
hi!

On Sat, Jul 14, 2012 at 5:00 AM, Andy Joslin <andyt...@gmail.com> wrote:
> It's because you are trying to get the length of an object. If you type
> '{}.length' in the console it will also return undefined.

Yep, Andy is right, it boils down to counting properties of an object
(http://stackoverflow.com/questions/126100/how-to-efficiently-count-the-number-of-keys-properties-of-an-object-in-javascrip)

Here is the working jsFiddle: http://jsfiddle.net/pkozlowski_opensource/pX7bE/2/

Cheers,
Pawel
Reply all
Reply to author
Forward
0 new messages