How to copy generated html content inside ng-repeat into a textarea?

0
<div ng-repeat="(keyC, column) in columns.form" ng-model="columns.form"  >
  <div class="well">
     <p><strong>BLOCO {{ keyC }}</strong></p>
      <div ng-repeat="(keyP, p) in column.perguntas" ng-model="column.perguntas"  >
          <formulario  data="p" ></formulario>
      </div>
  </div>
</div>

How to copy the content that was generated in the DOM to a textarea ? In fact, only a few things should be generated within textarea :

<div class="well">
   <p><strong>BLOCO 0</strong></p>
   <div class="alert alert-danger">88888</div>         
</div>
<div class="well">
   <p><strong>BLOCO 1</strong></p>
   <div class="alert alert-danger">123123123</div>         
</div>

Jsfiddle for better explanation: link

I tried to do this, but I think it's totally wrong:

<div ng-init="html = ''"></div>
<div ng-repeat="(keyC, column) in columns.form" ng-model="columns.form"  >
  {{ html += '<div class="well">' }}
    {{ html += '<p><strong>BLOCO' + keyC '</strong></p>' }} 
      <div ng-repeat="(keyP, p) in column.perguntas" ng-model="column.perguntas"  >
          {{ html += '<formulario  data="p" ></formulario>' }} 
      </div>
  {{ html += '</div>' }}
</div>

<textarea ng-model="html"></textarea>
    
asked by anonymous 20.02.2017 / 14:46

1 answer

0

I was able to get the html through JQuery Lite that comes embedded in the Angular. I put a id in the initial ng-repeat and I created a button with the function to put the html in the model follows the link of my JsFiddle - link

$scope.seta=function(){
    $scope.textarea = angular.element(document.querySelectorAll('#id')).html();
}

Explanation:

%% of native Javascript selector

document.querySelectorAll() will transform the passed object into a jquery lite object (if you have placed the dependency of JQuery on your project it will be a JQuery object)

angular.element() Jquery method that returns the html content of the JQuery object

    
20.02.2017 / 15:41