gpt4 book ai didi

javascript - 在 ng-repeat 中的 ng-click 上显示隐藏的 div

转载 作者:行者123 更新时间:2023-12-03 04:19:41 25 4
gpt4 key购买 nike

$scope.editPostComment = false;

当我单击btn时,它会在所有重复项目中显示textarea,而我只想在单击的div上显示它!

 <div class="commentBox" ng-show = "editPostComment" >
<textarea name="editor2" class="content-box allfilecomment" id="comment-box" focus-me="{{focusCommentBox}}"
ng-model="allCommentText"
markdown-editor="{'iconlibrary': 'fa', addExtraButtons: true, resize: 'vertical'}"
rows="10" >

</textarea>
<div class="hints">
<span class="boldtext">**Bold**</span>
<span class="italictext">_itlaics_</span>
<span class="striktext">~~strike~~</span>
<span class="codetext">'code'</span>
<span class="codetext">'''preformatted'''</span>
<span class="quotetext">>quote</span>
</div>
<div id="comment-btns">
<button class="btn btn-primary pull-left" ng-class="{'loading': commentig}" ng-disabled="commentig" ng-click="postAllComment(commentmode)">Edit</button>
</div>
</div>

最佳答案

您需要使用索引为每一行指定一个 ID,然后根据该 ID 使该行可见。

function showEdit(id) {
vm.editPostComment = id;

}
 

<div ng-repeat="row in rows track by $index">
<div class="commentBox" ng-show = "editPostComment == $index" >
<textarea name="editor2" class="content-box allfilecomment" id="comment-box" focus-me="{{focusCommentBox}}"
ng-model="allCommentText"
markdown-editor="{'iconlibrary': 'fa', addExtraButtons: true, resize: 'vertical'}"
rows="10" >

</textarea>
<div class="hints">
<span class="boldtext">**Bold**</span>
<span class="italictext">_itlaics_</span>
<span class="striktext">~~strike~~</span>
<span class="codetext">'code'</span>
<span class="codetext">'''preformatted'''</span>
<span class="quotetext">>quote</span>
</div>
<div id="comment-btns">
<button class="btn btn-primary pull-left" ng-class="{'loading': commentig}" ng-disabled="commentig" ng-click="showEdit($index)">Edit</button>
</div>
</div>
</div>

关于javascript - 在 ng-repeat 中的 ng-click 上显示隐藏的 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44003073/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com