title: clone/copy DOM element function not working properly
body: <blockquote>
    <p>My question is different than <a href="https://stackoverflow.com/questions/44581556/need-to-clone-the-selected-div-angular-2">this</a> because that code is not working on clicking the clone button, i have explained how that code is working with the help of an video. I am not getting any response on that thread so after waiting for 3 days, i am posting this question for further help.</p>
  </blockquote>
  
  <p>I have a very basic requirement. When i right click on a element it shows a context menu, this menu has a <code>clone</code> button. What i want is when this button is clicked it should clone or copy the same element next to this selected element.</p>
  
  <p>Problem i am facing, when i right click > i get the menu > when i click on clone my function will not return value, it will return value if i again right click, secondly i am unable to append it below selected text, below is my code:</p>
  
  <p>My <code>editpage.ts</code> code, function used is <code>clone()</code> </p>
  
  <pre><code>//for clone
    clone(){
      console.log("clone function here");
    document.addEventListener("contextmenu", (e) =&gt; {
    e.preventDefault();
    console.log(e, e.srcElement.outerHTML);
    this.htmlstring = e.srcElement.outerHTML;
  });
    }
  
    // code for right click context menu
    rightPanelStyle: Object = {};
  
    detectRightMouseClick($event) {
      // disabling the default browser window which comes on right click
      document.addEventListener('contextmenu', event =&gt; event.preventDefault());
  
         if($event.which === 3) {
             this.rightPanelStyle = {'display':'block','left':$event.clientX + 'px','top':$event.clientY + 'px'};
              return false;
         }
    }
  </code></pre>
  
  <blockquote>
    <p>Below showing a small 20 second video of what exactly is happening - <a href="http://youtu.be/I4nAb77lk_Q?hd=1" rel="nofollow noreferrer">http://youtu.be/I4nAb77lk_Q?hd=1</a></p>
  </blockquote>
  
  <p>Please please help</p>