【发布时间】:2016-09-16 08:43:21
【问题描述】:
这是我的 .html:
<ul class="messages list-unstyled" ng-repeat="newMessage in messages">
<li>
<p>
<span class="username">{{newMessage.username}}</span><br />
</p>
<p>
<span> {{newMessage.message}}</span>
</p>
<p class="no-pad-bottom date-posted">Send {{ newMessage.date }} <span /></p>
<div class="comments">
<ul class="list-unstyled" ng-repeat="newComment in comments">
<li>
<p>
<span class="commentor"> {{newComment.username}}</span>
<span> {{newComment.message}}</span>
</p>
<p class="no-pad-bottom date-posted">Send {{ newComment.date }} <span /></p>
</li>
</ul>
<form class="add-comment">
<div class="row">
<div class="col-md-10">
<input type="text" class="form-control" ng-model="myComment" placeholder="Add a comment" />
</div>
<div class="col-md-2">
<button class="btn btn-default btn-sm" type="submit" ng-click="addComment(newMessage.id)">Comment</button>
</div>
</div>
</form>
</div>
</li>
</ul>
一切正常。我可以发送消息,甚至可以发送帖子,但是我从 ng-model="myComment" 得到 null
这是js控制器中的方法
$scope.addComment = function (messageId) {
myChatHub.server.addComment(messageId, userName, $scope.myComment);
};
你能告诉我有什么问题吗?
【问题讨论】: