How to create a custom template controller in Aurelia?

In Angular, they have Structural Directives or Other Structural Directives so they can create custom if, switch,…

In one of the above examples, He created a custom loop as *appNgLoop.

AFAIK, we call them Template controller. Can we create custom template controller in Aurelia or Aurelia vNext too? If yes please guide me.

Well actually if and repeat are just custom attributes in Aurelia. So yes it’s definitely doable. I’d recommend taking a look at their implementation linked above.

1 Like

Here is another simpler example

It uses ViewSlot, View. For understanding purposes, I would suggest looking into if / else code, it’s way simpler than the repeat beast


How sophisticated! Far from Aurelia way. I expected a simpler approach. :disappointed:

For example?


Dear @davismj

I have no idea. just I thought it should be easier. At first glance, it seems hard.

@HamedFathi you could view it in this angle.

We know software is built on top of stack of layers of abstraction. To make your code (the top layer) simple and intuitive, aurelia has to hide complexity beneath. Because to the end users of your app, who see your app as a black box, the total complexity is almost constant, no matter what tech stack you chose to build it.

Some layer has to absorb the complexity. Simple and intuition is relative to which layer you are looking at.