input tag inside ng-repeat angularjs

hardi fatih

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>

Varedis

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] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

AngularJS ng-repeat in this model

분류에서Dev

AngularJS IF ELSE with ng-repeat

분류에서Dev

AngularJS ng-repeat in modal

분류에서Dev

<tr ng-repeat>를 사용한 AngularJS <input> 유효성 검사

분류에서Dev

Updating input values from selected option in dropdown in ng-repeat Angularjs

분류에서Dev

Angularjs Nested ng-repeat with conditional caluse

분류에서Dev

Angularjs ng-repeat 새 요소

분류에서Dev

AngularJs ng-repeat in group class

분류에서Dev

AngularJs ng-repeat by track by not updated

분류에서Dev

AngularJs. ng-repeat 문제

분류에서Dev

Ng repeat error on form validating angularjs dupes

분류에서Dev

Show ng-repeat selectively in AngularJs

분류에서Dev

ANgularjs: ng-repeat and nested custom directive

분류에서Dev

AngularJS - check for null item in ng-repeat

분류에서Dev

Accessing Controller variable in ng-repeat in AngularJS

분류에서Dev

AngularJS-ng -repeat 문제

분류에서Dev

Angularjs orderBy in ng-repeat not working as expected

분류에서Dev

AngularJs Json Ng-repeat with Button Control

분류에서Dev

ng-repeat의 AngularJS 직렬

분류에서Dev

ng-repeat로 angularJS 루프

분류에서Dev

AngularJS : ng-repeat the list but with titles and grouped by

분류에서Dev

How to manipulate many elements inside an ng-repeat?

분류에서Dev

Jquery Time Picker inside ng-repeat is not working

분류에서Dev

angularjs ng-controller inside ng-controller

분류에서Dev

AngularJS ng-repeat 인덱스 제한?

분류에서Dev

AngularJS ng-repeat 엉망진창

분류에서Dev

AngularJS ng-repeat 엉망진창

분류에서Dev

AngularJS : 동적 데이터로 ng-repeat

분류에서Dev

AngularJS 여러 tr에 걸쳐 ng-repeat