3

I need to inject instances of a custom html-component dynamically, and it would be really useful to be able to "$digest" a template on the fly. How can I do this in angular2? Right now I have this:

let html = `<custom-element>Content</custom-element>`;
let template = document.createElement('template');
template.innerHTML = html;
document.getElementById('app')
    .appendChild(template.content.firstChild)

But this just inserts a plain 'ol element.

http://puu.sh/nKBz8/89825fbb78.png

Here is a plunker showing the way I am trying to do it:

http://plnkr.co/edit/JqLWpD?p=preview

Dylan Harness
  • 719
  • 1
  • 9
  • 20

0 Answers0