title: Convert compiled dom to html code in angularjs
body: <p>I wrote a directive which has a <code>postLink</code>, and I compiled some html code and render it by angularjs. But the problem is I can't get the html code from the generated DOM.</p>
  
  <p>My code is:</p>
  
  <pre><code>app.directive("showResultAsText", ['$compile', function ($compile) {
      return {
          restrict: 'A',
           compile: function compile(tElement, tAttrs, transclude) {
              console.log('compile');
              var watchModal = tAttrs["showResultAsText"];
              var elem = jQuery(tElement);
              var oriHtml = elem.html();
              elem.empty();
              return {
                  post: function postLink(scope, iElement, iAttrs, controller) {
                      scope.$watch(function () {
                          return scope.$eval(watchModal);
                      }, function (newVal) {
                          if (newVal) {
                              var s = $compile(angular.element(oriHtml))(scope);
                              console.log(s);
                              console.log(s[0]);
                              console.log(s[0].outerHTML);
                              console.log($('&lt;div&gt;').append(s[0]).html());
                              iElement.text(s[0].outerHTML);
                          }
                      });
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>You can see I used <code>console.log</code> to print the value of <code>s</code>. And in the console, it outputs:</p>
  
  <p><img src="https://i.stack.imgur.com/Bvpb9.jpg" alt="enter image description here"></p>
  
  <p>You can see <code>console.log(s)</code> and <code>console.log(s[0])</code> have many information, but when I use <code>outerHTML</code>,  the inner buttons are all missing.</p>
  
  <p>I also tried to use jquery: <code>jQuery(s[0]).html()</code>, but the same happened.</p>
  
  <p>What is the correct way of convert that <code>s</code> to html code?</p>