我正在开展一个项目,我必须执行社交媒体等操作,我坚持在一个我必须评论的阶段,然后我必须重置那个可编辑的div。 可编辑的Div代码:
<div id="txtComment" contenteditable="true" class="form-control txtComment" style="height: 156px; margin-bottom: 10px;">
我的按钮用于调用注释功能代码:
<input type="button" value="POST" ng-click="comment(<?php echo $itemId ?>,<?php echo $itemDesc ?> ,user_comment,0,0,mood)">
我的职能:
$scope.comment=function (itemid, itemdescid,user_comment,replyId,parentcomId,mood)
{
var feeling="";
//console.log(mood);
if (typeof mood !== "undefined")
{
feeling=mood;
//console.log(mood+"test");
}
var comm="";
if(replyId==0)
{
comm=$("#txtComment").html();
}else if(replyId == parentcomId)
{
comm=$("#"+parentcomId+"comment").html();
//console.log(comm);
} else
{
comm=$("#"+replyId+"comment").html();
}
console.log(comm);
//console.log(feeling);
var req = {
method:"POST",
data:{item_Id:itemid, item_desId:itemdescid, comment:comm,commentReplyId:replyId,parent_commentId:parentcomId,User_feeling:feeling,userId:$scope.id},
url:"<?php echo base_url()?>index.php/ItemImportance/Comment",
headers: {
'Content-Type': 'application/json'
},
};
$http(req).then(function (response) {
if (response.data !=null)
{
if(response.data.msg !=null)
{
alert(response.data.msg);
}
else
{
//var scopeNmae="item"+"_"+itemid+"_"+itemdescid;
// console.log(scopeNmae);
//$scope[scopeNmae]=response.data;
//console.log(response.data);
// window.location.reload();
$scope.itemcomments=response.data;
//eraseText();
}
} else
{
}
}, function (response) {
console.log(response)
});
}
我要做的就是在点击评论按钮后清空我的可编辑div! 请尽快帮助我。
答案 0 :(得分:0)
我写了一个非常简单的例子plnkr,请看一下。
<body ng-controller="MainCtrl">
<textarea ng-model="comment" placeholder="comment"></textarea>
<button ng-click="comment = ''">Clear</button>
</body>
我的推荐是:
编辑:
包含内容可编辑div的示例plnkr。这是AngularJS website的一个分支,我刚刚添加了清除按钮。