So I decided to take Aurelia 2 for a spin (after attending the “Swetugg” conference in Stockholm this week ).
Using npx makes aurelia
as the starting point I got the application running and created a simple custom element;
box.ts;
export class Box {
color: string = 'red';
}
box.html;
<div css="width: 50px; height: 50px; background-color: ${color};"></div>
This works fine using <import from="custom-elements/box/box"></import>
and <box></box>
within my-app.html.
I can use chrome dev tools to see that the html file is included;
However, as soon as I add the @customElement
decorator to the class;
import { customElement } from 'aurelia';
@customElement('box')
export class Box {
color: string = 'red';
}
the .html template is no longer loaded;
In the above case, obviously the ´@customElement` decorator doesn’t serve any purpose, but what I would like to, and what we’re doing in “v1”, is to always prefix the tag name on our own custom elements;
/.../
@customElement('vkau-box')
export class Box {
/.../
so the usage would be;
<vkau-box></vkau-box>
We do this to simplify the introduction of new developers, to make it clear what components are our own as well as making sure our own components wont clash with some built in or third party components that might exist.
Why is the html template not loaded as soon as I add the @customElement
decorator?