0

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

Joachim Seminck
  • 721
  • 1
  • 8
  • 10

1 Answers1

1

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.

Miroslav Popovic
  • 12,100
  • 2
  • 35
  • 47
  • Thanks a lot! That works indeed. I understand this is mentioned in the docs but the docs are huge and I don't think I would have found this detail in there easily. :) – Joachim Seminck Aug 09 '16 at 05:29