admin管理员组文章数量:1355670
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.
Controller
//task.descr contains "<br>-------<br><a href=""..."
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>
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.
Controller
//task.descr contains "<br>-------<br><a href="http://www.google."..."
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>
Share
Improve this question
edited May 11, 2015 at 15:11
scniro
17k8 gold badges66 silver badges107 bronze badges
asked Mar 7, 2015 at 4:08
xyonmexyonme
4051 gold badge8 silver badges24 bronze badges
3
- Can't markup in textarea – reptilicus Commented Mar 7, 2015 at 4:19
- if not using text area,what is the best way to render the HTML values as well as for ng-model? – xyonme Commented Mar 7, 2015 at 4:24
- 1 use contenteditable for the div and achieve the same result :) – mohamedrias Commented Mar 7, 2015 at 4:48
1 Answer
Reset to default 5This would allow you have both two way data binding as well as give you the functionality of textarea:
<div ng-bind-html="modelname"
contenteditable="true"
ng-model="modelname">
</div>
DEMO
本文标签: javascriptAngularJS Render HTML in textareaStack Overflow
版权声明:本文标题:javascript - AngularJS Render HTML in textarea - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744044091a2581202.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论