I want to achieve an extension of an HTML tag with an attribute, but encapsulate it with an angular 2 component.
Suppose the original markup uses my angular 2 foo component
<div foo="x"></div>
The foo attribute should convert the div to:
<div some-other-fancy-attribute="x"></div>
At first I tried to implement the directive, but I could not figure out how to add another attribute to the hosting element using Renderer from angular / core.
Then I read about angular 2 components using an attribute selector like [foo]. I liked the idea of ββusing a template to display the some-other-fancy attribute.
However, the template gets render AFTER the tag, so I get:
<div foo="x">some-other-fancy-attribute="x"
Is there an easy way to encapsulate the creation of an attribute? Thought it was trivial, but it gives me more headache than expected.
source share