Why I am using inside ng-repeat tag it is not working. When I push the button to send the data to the server, it is not going push data but it sends null as I check my mongodb.
This is not happening if I move the input area out of ng-repeat
<h3 ng-repeat="review in reviews" class="icon">
<span class="glyphicon glyphicon-user " aria-hidden="true"></span>
<small >{{review.username}} </small>
<small style="float: right;">{{review.mydate}} </small>
<hr class="hr">
<div class="content">
{{review.text}}
</div>
<hr class="hr">
<div >
<a href ng-click="addLike(review)"><span class="glyphicon glyphicon-thumbs-up" aria-hidden="true"></span></a>
<span class="glyphicon glyphicon-comment" aria-hidden="true"></span>
<span class="glyphicon glyphicon-share-alt" aria-hidden="true"></span>
<a href ng-click="removeReview(review)"> <span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>
<hr>
**<div class="newComment" ng-show='currentUser' >
<input type="text" placeholder="Pleae post your comment here..."
ng-model="newComment"
>
<button ng-value="string" type="button" class="btn btn-default"
ng-click="submitNewComment(newComment)">Comment</button>
</div>**
<ul>
<li>
{{review.comments}}
</li>
</ul>
You are likely falling into scoping issues, each ng-repeat
creates it's own scope but you are assigning ng-model
to a single scoped item so you are getting null
from another item.
Try writing your new comment section like:
<div class="newComment" ng-show='currentUser' >
<input type="text" placeholder="Please post your comment here..."
ng-model="review.newComment">
<button ng-value="string" type="button" class="btn btn-default"
ng-click="submitNewComment(review.newComment)">Comment</button>
</div>
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다