[ ng-repeat nested data repeats through empty values ]
I have activity controller in rails that renders the below json output.
{"id":3,"trackable_id":6,"trackable_type":"Movie","owner_id":1,"owner_type":"User","key":"movie.create","parameters":{},"recipient_id":null,"recipient_type":null,"created_at":"2015-12-30T12:31:24.765Z","updated_at":"2015-12-30T12:31:24.765Z",
"owner":{"id":1,"email":"peter@peter.nl","provider":null,"uid":null,"name":"Peter Boomsma","username":null}},
{"id":2,"trackable_id":5,"trackable_type":"Movie","owner_id":1,"owner_type":"User","key":"movie.create","parameters":{},"recipient_id":null,"recipient_type":null,"created_at":"2015-12-30T11:55:06.766Z","updated_at":"2015-12-30T11:55:06.766Z",
"owner":{"id":1,"email":"peter@peter.nl","provider":null,"uid":null,"name":"Peter Boomsma","username":null}},
In my activity template I have this ng-repeat,
%ul{"ng-repeat" => "activity in activities"}
%li{"ng-repeat" => "owner in activity"}
Full Name: {{owner.name}}
But it looks like the ng-repeat is looping through every value in both the parent and child object because the output looks like this,
Full Name:
Full Name:
Full Name:
Full Name:
Full Name:
Full Name:
Full Name:
Full Name:
Full Name:
Full Name:
Full Name:
Full Name: John Doe
Full Name:
Full Name:
Full Name:
Full Name:
Full Name:
Full Name:
Full Name:
Full Name:
Full Name:
Full Name:
Full Name:
Full Name: John Doe
Full Name:
Full Name:
Full Name:
Full Name:
Full Name:
Full Name:
Full Name:
Full Name:
Full Name:
Full Name:
Full Name:
Is this approach of rendering incorrect or am I just doing something wrong?
Answer 1
There seems to be just a single owner per activity:
%ul{"ng-repeat" => "activity in activities"}
%li // Remove the ng-repeat here
Full Name: {{activity.owner.name}}
This should work for you.
Apologies! Not sure about the exact syntax used here