Answer the question
In order to leave comments, you need to log in
How to display nested data in a loop?
Hello!
I take an array of data (comments) from the database, each comment can have a nested comment, and a nested comment can have a child comment, and so on.
Array example:
"models": [
{
"id": "122",
"id_user": "3",
"page": "Art-87",
"id_parent": "0",
"text": "йцуцуйцуйцу йцуйцуцйуцйу",
"date_create": "2015-10-09",
"time_create": "1444383408",
"full_name": "Администратор",
"service": "zagamay",
"status": "1",
"ip_user": "127.0.0.1"
},
{
"id": "121",
"id_user": "3",
"page": "Art-87",
"id_parent": "0",
"text": "Тестовое соощение Два",
"date_create": "2015-10-09",
"time_create": "1444382461",
"full_name": "Администратор",
"service": "zagamay",
"status": "1",
"ip_user": "127.0.0.1",
"Child": [
{
"id": "123",
"id_user": "3",
"page": "Art-87",
"id_parent": "121",
"text": "фывыфвфыв ыфвфывфыв фывфывфывфы вфыв",
"date_create": "2015-10-09",
"time_create": "1444383578",
"full_name": "Администратор",
"service": "zagamay",
"status": "1",
"ip_user": "127.0.0.1",
"Child": [
{
"id": "125",
"id_user": "3",
"page": "Art-87",
"id_parent": "123",
"text": "фывыфвфыв ыфвфывфыв фывфывфывфы вфыв",
"date_create": "2015-10-09",
"time_create": "1444383584",
"full_name": "Администратор",
"service": "zagamay",
"status": "1",
"ip_user": "127.0.0.1",
"Child": [
{
"id": "120",
"id_user": "3",
"page": "Art-87",
"id_parent": "125",
"text": "Тестовое сообщение",
"date_create": "2015-10-09",
"time_create": "1444382324",
"full_name": "Администратор",
"service": "zagamay",
"status": "1",
"ip_user": "127.0.0.1",
"Child": [
{
"id": "124",
"id_user": "3",
"page": "Art-87",
"id_parent": "120",
"text": "фывыфвфыв ыфвфывфыв фывфывфывфы вфыв",
"date_create": "2015-10-09",
"time_create": "1444383581",
"full_name": "Администратор",
"service": "zagamay",
"status": "1",
"ip_user": "127.0.0.1"
}
]
}
]
}
]
}
]
}
],
<div ng-repeat="item in comments.models">
<!-- Вывод данных -->
</div>
Answer the question
In order to leave comments, you need to log in
recursive patterns?
benfoster.io/blog/angularjs-recursive-templates
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question