2017-06-13 89 views
0

我正在使用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> 

view

+0

分享您的代碼,請! –

+1

[如何問](https://stackoverflow.com/help/how-to-ask) – Maher

+0

我相信,你是美國var從對象重複,嘗試創建一個var在同一個對象重複的按鈕,請分享您的代碼,並會更好地幫助您 –

回答

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>

+0

我不清楚在哪裏顯示'textbox'? –

+0

under replay button.like堆棧溢出添加評論 – umapathi

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> 

期待它可以幫助你

+0

視圖正在工作,當我點擊按鈕被禁用。但文本框不顯示 – umapathi

+0

我要求文本框啓用當我點擊button.but這裏按鈕被禁用。你可以添加一些更多的文本框代碼。 – umapathi

相關問題