以下是angular.js形式的线程注释的结构。
<form>
<ul class="unstyled">
<!-- ng-class="{ '{{childcond}}': $index == selectedIndex }" -->
<li ng-repeat="comment in comments" class="{{childcond}}" ng-init=" childcond=checkChild(comment.slug); reply.parentSlug=comment.slug; idstring=slashRemove(comment.slug);" >
<strong>{{comment.author}}</strong><br>
<p>
{{comment.body}}
</p>
<a href="javascript:void(0)" class="replycomment" >reply</a>
<div id="{{idstring}}" style="display:none;" >
<input type="text" placeholder="Your Name" ng-model="reply.replyAuthor"><br>
<span style="display:none;">
<input type="text" class="hidevalue" ng-model="reply.parentSlug" ng-value="{{comment.slug}}" >
</span>
<textarea name="" id="" cols="30" rows="10" placeholder="Comment" ng-model="reply.replyBody"></textarea>
<input class="btn-primary" type="submit" value="reply" ng-click="replyComment(reply,$index)">
</div>
</li>
</ul>
这是我在angular.js文件中的回复代码。
$scope.replyComment = function(reply,$index) {
socket.emit('comment', { author: reply.replyAuthor,
body: reply.replyBody,
parent_slug:reply.parentSlug });
clearForm();
};
socket.on('comment', function(comment) {
$scope.$apply(function() {
console.log(comment);
$scope.comments.push(comment);
});
});
console.log(comment)给出了以下结构。