1
ng-model
값을 ng-attr-id
까지 얻을 수있는 방법이 있습니까?각도 : ng-attr-id로 ng-model을 얻으시겠습니까?
저는 답글 상자를 만들고 있는데 현재 답변의 가치를 얻고 싶습니다. 여기
은 여기 내 html--<div class="comments-list" ng-show="CommentsLoaded">
<ul>
<li ng-repeat="comment in comments">
<div>
{{comment.content}}
</div>
<div ng-click="showReply(comment.id)">
Reply
</div>
<div ng-class="hideReply" ng-attr-id="{{'reply-'+comment.id}}">
<textarea ng-model="replytxt" ng-attr-id="{{'replytxt-'comment.id}}"></textarea>
<div class="form-group">
<button type="button" ng-click="sendReply(comment.id)">
Publier
</button>
</div>
</div>
</li>
</ul>
</div>
입니다 콘솔에서 이것을 angularjs--
$scope.sendReply = function(commentId){
var elm = document.getElementById('replytxt-'+commentId);
console.log(elm);
}
위의 기능 쇼 :
<textarea ng-model="replytxt" ng-attr-id="{{'replytxt-'+comment.id}}" class="ng-pristine ng-valid ng-touched" id="replytxt-31"></textarea>
잘 작동합니다. 귀하의 제안은 제 것보다 낫습니다. 고마워요 –
@AmadouBeye 다행을 알고, 감사합니다;) –