List html in a textarea


I know that to list in html code is:

  <li>Este será el 1. </li>
  <li> Este será el 2. Y así sucesivamente. </li>

The fact is that I need it in a textarea or in some way. I need to make the user answer a question and list their answers, but the user does not put "1-" but it automatically comes out.


  • The response will be sent in a POST form to be saved later in the BBDD
  • If the answer is already answered, it is loaded like this, you can edit it again

    <div ng-repeat="resp in respuestas">
asked by sirdaiz 13.07.2017 в 09:35

2 answers


It's enough that you create a div that is editable and put the list structure inside. Each time you enter, the next number comes out automatically.

I use a div because a textarea does not interpret the from the interior.

div.editable {
  width: 300px;
  height: 100px;
  border: 1px solid #ccc;
  padding: 5px;
  overflow: auto;
  <div contenteditable="true" class="editable" id="divEditable">

      <li>Este será el 1. </li>
      <li> Este será el 2. Y así sucesivamente. </li>

answered by 13.07.2017 в 09:58

Well to achieve your goal you can use ng-repeat on an array or an array-json and you're showing with {{}} for each iteration. note that .id is an attribute of the array-json

var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
  $scope.records = [
<script src=""></script>
<div ng-app="myApp">
  <div ng-controller="myCtrl">
    <div ng-repeat="x in records">{{}}.- {{}}</div>
answered by 20.07.2017 в 03:25