我正在使用ng-repeat打印数据。我添加了一个重播按钮。基于重播按钮下的回复按钮启用文本框。
但是当我点击重播按钮时,文本框会启用所有重播按钮。
谢谢......!
控制器代码
getForumOnIdAnswer(fAnsId);
function getForumOnIdAnswer (fAnsId){
ForumRepository.getForumOnIdAnswer(fAnsId)
.then(function (response){
scope.forumAnswer=response;
},
function(errResponse){
console.error('Error while fetching forumAnser');
}
);
};
html代码
<div ng-repeat="forumAnswerData in forumAnswer">
<div class="panel-group">
<div class="panel panel-success">
<div class="panel-heading">
<a href="">{{forumAnswerData.farmer.firstName}}</a>
<div class="pull-right">{{ forumAnswerData.answerDate |
date:"MM/dd/yyyy 'at' h:mma" }}</div>
</div>
<div class="panel-body">{{forumAnswerData.answer}}</div>
<div class="panel-footer">
<button type="button" class="btn btn-danger" ng-click="">Reply</button>
</div>
</div>
</div>
</div>
答案 0 :(得分:2)
应该是这样的。只是为了启用文本框。
<div ng-repeat="forumAnswerData in forumAnswer">
<div class="panel-group">
<div class="panel panel-success">
<div class="panel-heading">
<a href="">{{forumAnswerData.farmer.firstName}}</a>
<div class="pull-right">{{ forumAnswerData.answerDate | date:"MM/dd/yyyy 'at' h:mma" }}</div>
</div>
<div class="panel-body">{{forumAnswerData.answer}}</div>
<div class="panel-footer">
<textarea ng-model="yourModel" ng-show="$index ==currentTextBox"></textarea>
<button type="button" class="btn btn-danger" ng-click="currentTextBox = $index">Reply</button>
</div>
</div>
</div>
</div>
答案 1 :(得分:0)
我认为可以使用您自己的转发器的代码是:
<div ng-repeat="forumAnswerData in forumAnswer" ng-init="forumAnswerData.buttonEnabled=false;">
<div class="panel-group" ng-click="forumAnswerData.buttonEnabled=true">
<div class="panel panel-success">
<div class="panel-heading">
<a href="">{{forumAnswerData.farmer.firstName}}</a>
<div class="pull-right">{{ forumAnswerData.answerDate |
date:"MM/dd/yyyy 'at' h:mma" }}</div>
</div>
<div class="panel-body">{{forumAnswerData.answer}}</div>
<div class="panel-footer">
<button type="button" class="btn btn-danger" ng-click="" ng-disabled="forumAnswerData.buttonEnabled">Reply</button>
</div>
</div>
</div>
</div>
期待它可以帮助你