The comments for an issue can be loaded in parallel, as we saw earlier, to issue details. While this is an option, we can also load it independently. Comments may have been put under their own component class and service class; that's when the logic and code grows, and we can keep it simple for this example. Here's how the comments can be loaded:
this.issuesService.getComments(this.issue.id).subscribe(result => {
this.comments = result;
});
Similarly, we can create a simple form to capture the text input of the comment and save it. Given the simplicity of the form, we can use the template-driven form approach here. The FormsModule will have to be imported into the IssuesModule. Then, the form can be created with HTML 5 validations, as shown here:
<form #commentForm="ngForm" (ngSubmit)="onComment(commentForm)" >
<input...