1

I have a bunch of templates such as

<template id="test"><span on-click="clickHandler">Click me!</span></template> 

and I want to instantiate them through code. Basically, these templates are some sort of prefab which gets created whenever I need them.

How can I do this?

I expect something like:

someElement.append( ($['test'] as TemplateElement).createInstance() );

What, if I have to pass arguments to the template?

<template id="test"><span on-click="clickHandler" item="{{item}}">Click me!

Basic Coder
  • 10,882
  • 6
  • 42
  • 75

0 Answers0