由于在某些特殊条件下(AMP),我在我的 angularjs 项目中使用 JQUERY。
<div data-ng-repeat = "comment in blog.comments">
<i class="icon-edit font20 edit-faq-icon pointer" id="edit-comment" data-ng-click="editComment(comment);"></i>
</div>
以前我有ng-click,现在只能通过jquery查找事件。
$('#edit-comment').click(function(){
alert('hi');
})
但我想访问函数 editComment(comment)
中传递的参数(comment
)。
最佳答案
在 Angular Controller 中编写一个范围函数,如下所示。您将获得评论作为参数。
$scope.editComment=function(comment)
{
$scope.comment=comment;
};
像这样设置 html 内容。
<div ng-model="comment" id="Comment"></div>
现在您可以使用 $('#Comment').val()获取click中的值
关于javascript - jquery中如何获取div的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43731450/