javascript AngularJS 在 textarea 中渲染 HTML
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28911256/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 09:44:54 来源:igfitidea点击:
AngularJS Render HTML in textarea
提问by xyonme
I need to render HTML values in text area SUBMIT FORM.
I can bind the html values in a <div>
but not in a <textarea>
.
Also, ng-model
for data binding can retrieve the value but it is displayed as html.
我需要在文本区域提交表单中呈现 HTML 值。我可以在 a 中绑定 html 值,<div>
但不能在 a 中绑定<textarea>
。此外,ng-model
对于数据绑定可以检索该值,但它显示为 html。
Controller
控制器
//task.descr contains "<br>-------<br><a href="http://www.google.com"..."
var str="<br><hr><br>"+ task.descr;
//str= $sce.trustAsHtml(str);
$scope.formData5 = {
descr: str}
console.log($scope.formData5);
<textarea placeholder="Deskripsi Memo" name="descr"
ngMaxlength="1000" ng-model="formData5.descr"
ng-bind-html="formData5.descr" > </textarea>