Aurelia: How to add and remove custom attributes from view-model -


how add , remove custom attributes view-model?

adding attribute targetelement.setattribute('mycustomelement') won't activate aurelia custom attribute.

could templatingengine.enhance() bring life custom-attribute view-model?

you can this:

<div id="dummy">lorum ipsum</div> <button click.delegate="addattribute()">click here</button> 

with code behind

public addattribute() {      let el = document.getelementbyid("dummy");     el.setattribute("css.bind", "{ color: 'red' }");      if (el && !el.queryselectorall('.au-target').length) {       var element = this.templatingengine.enhance(el);       console.dir( element.viewfactory );     } } 

don't know how unbind , (i guess) give either memory problems or errors when attach element multiple times (so added check .au-target). documentation above function says responsible life cycle of it.

what try accomplish? there might better way..


Comments