const comments:Comment[] = [
{
text: "1",
comments: [
{
text: "1.1",
comments: [
{
text: "1.1.1 "
}
]
},
{
text: "1.2",
comments: [
{
text: "1.2.1"
}
]
}
]
},
{
text: "2",
comments: [
{
text: "2.1",
comments: [
{
text: "2.1.1"
}
]
}
]
}
];
@Component({
selector: 'comments',
template: `
<div *ngFor="let comment of comments">
<ul>
<li>
{{comment.text}}
<comments [comments]="comment.comments"
*ngIf="comment.comments"></comments>
</li>
</ul>
</div>
`,
})
export class CommentComponent {
@Input() comments;
}
@Component({
selector: 'my-app',
template: `
<comments [comments]="postComments"></comments>
`,
})
export class App {
postComments = postComments;
}
К сожалению, не доступен сервер mySQL