2

I had a code like below in angularjs 1

var htmlval = $compile(myWindow.document.getElementById("myDiV").outerHTML)($scope);

which i was using to get the scope compiled to html and get the final dom. Angular 4 we don't have scope. Is there a way to do the same. I was using this for getting data to be printed.

Hacker
  • 7,798
  • 19
  • 84
  • 154
  • Whay are you trying to do ? do you want to get the outerHTML ? – Sadok Mtir Aug 04 '17 at 10:43
  • 1
    `ngTemplateOutlet` directive can take `template` and `context` – yurzui Aug 04 '17 at 10:43
  • can you show the contents of the `myDiV` element? See also this article which shows how to use $compile in Angular [Here is what you need to know about dynamic components in Angular](https://hackernoon.com/here-is-what-you-need-to-know-about-dynamic-components-in-angular-ac1e96167f9e), particularly `Creating components on the fly` section – Max Koretskyi Aug 04 '17 at 11:34
  • Dup of https://stackoverflow.com/questions/34784778/equivalent-of-compile-in-angular-2 – yurzui Aug 04 '17 at 11:37

0 Answers0