1

I have a simple custom elemen, but it is not rendering.

If i do <require from="./myfooter.html"></require> then it renders only the html part. But if i do <require from="./myfooter"></require> then nothing is rendered.

What am i doing wrong?

    @inject(ConfigService)
export class MyFooterCustomElement{
    private version: string;
    constructor(
        private configService: ConfigService) {
        this.getVersion()
    }



<template>
    <footer class="footer fixed-bottom d-flex justify-content-between">
        <span class="p-2 ml-40">text</span>
        <span class="text-muted d-flex p-2">v${version}</span>
    </footer>
</template>
    async getVersion() {
        this.version = await this.configService.getVersion();
    }
}
  • 1
    I can't see anything obiously wrong, please try to reproduce your issue on codesandbox: codesandbox.io/s/zw9zjy0683 – Arne Deruwe Apr 11 at 14:43
  • 2
    aurelia default rendering is based on naming convention. rename the class from MyFooterCustomElement to MyFooter, also: when using TS you can write @autoinject() instead of @inject(ConfigService). – avrahamcool Apr 11 at 21:54
  • 1
    also: the template seems to be in the TS file, is this a mistake in your code? or you just posted it wrong here? – avrahamcool Apr 11 at 21:56
  • @avramcool jep the naing conventsion was the issue. I read fro maurelia tutorial that aurelia wants the "CustomElement" to the end si i put it there, bit aparently it was false :D. it works now. – Marko Taht Apr 15 at 7:04
  • @MarkoTaht Ill put that in an answer, so you can accept it and close the question. – avrahamcool Apr 15 at 16:37
1

aurelia default rendering is based on naming convention.

rename the class from MyFooterCustomElement to MyFooter

also: when using TS you can write @autoinject() instead of @inject(ConfigService).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.