I started playing around with Aurelia (which is really nice), but quickly ran into an issue for which I cannot immediately find a solution.
I am using the Aurelia Skeleton projects from Github. Specifically I am using ESNext + WebPack. But my problem is consistent amongst the other projects as well.
https://github.com/aurelia/skeleton-navigation/tree/master/skeleton-esnext-webpack
The project includes a nav-bar.html
file which builds links based on the router
configuration. However I want to add custom logic to this navigation bar, in the form of an inline login form. Thus I need to attach a controller
to it.
Normally, in Aurelia this is done by creating a file with the same name as is mentioned everywhere. So I create nav-bar.js
and put all the logic there. But that doesn't work here... the nav-bar.js
file is not picked up and doesn't get connected to the template.
What's more is that I found out that none of the templates which I <require from="./myTemplate.html">
work with a controller in this project. Only the templates loaded in the router work with a controller.
That leads me to think that I'm missing some configuration that needs to be set up ... ?
Thanks
Instead of requiring HTML, require by name only:
<require from="./myTemplate"></require>
When you use .html
extension that hints the templating engine that you want to load view-only component, without view model. You can read more in Aurelia documentation hub.