Implementing the Comment View
As discussed in the previous section, the comment thread section of the page uses ng-include
to include the comment.html
partial, shown in Listing 27.13, for each reply in the comment object replies
array.
By using a partial template here, you can nest replies inside replies by simply reading the same block, shown below, to iterate through replies using ng-repeat
and using ng-include
to include the same form:
<div ng-repeat="comment in comment.replies" ng-init="reply=false;replySubject='';replyBody=''"> <div class="comment" ng-include="'/static/comment.html'"></div></div>
The comment.html
partial template includes the comment username, subject, timestamp, and body. An <input>
button ...
Get Node.js, MongoDB, and AngularJS Web Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.