0

I am using ng-repeat to printing data.here i added one replay button.based on reply button enable text box under replay button.

but when i click replay button text boxes are enable all the replay buttons.

Thank you...!

Controller Code

getForumOnIdAnswer(fAnsId); function getForumOnIdAnswer (fAnsId){ ForumRepository.getForumOnIdAnswer(fAnsId) .then(function (response){ scope.forumAnswer=response; }, function(errResponse){ console.error('Error while fetching forumAnser'); } ); }; 

html code

<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> 

view

8
  • share your code please!
    – Hadi
    CommentedJun 13, 2017 at 5:47
  • 1
    how-to-ask
    – Maher
    CommentedJun 13, 2017 at 5:47
  • i belive, your are usina var out from object repeated, try to create a var in same object repeated as the button,please share your code and will help you betterCommentedJun 13, 2017 at 5:48
  • @Hadi shared more code
    – Umapathi
    CommentedJun 13, 2017 at 5:54
  • @ÁlvaroTouzón i'm using ng-repeat.here how to enable text box clicking button
    – Umapathi
    CommentedJun 13, 2017 at 5:57

2 Answers 2

2

It should be like this. just for enabling textbox.

<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
  • under replay button.like stack overflow add comment
    – Umapathi
    CommentedJun 13, 2017 at 6:15
0

the code i think will work, using your own repeater in view is:

<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> 

Expect it helps you

2
  • the view is working and when i click button is disabled.but text box not displayed
    – Umapathi
    CommentedJun 13, 2017 at 6:10
  • I'm asking text box enable when i click button.but here button is disabled.can you add some more code for text box.
    – Umapathi
    CommentedJun 13, 2017 at 6:23

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.