2

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.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>
3
  • Can't markup in textarea 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? Commented Mar 7, 2015 at 4:24
  • 1
    use contenteditable for the div and achieve the same result :) Commented Mar 7, 2015 at 4:48

1 Answer 1

5

This 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

Sign up to request clarification or add additional context in comments.

2 Comments

I think content editable is a special directive. Please refer to: fdietz.github.io/recipes-with-angular-js/…
Two way data binding doesn't work. Add <p>{{inputText}}</p> and check

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.