Register Transient and AutoInject


I have a custom validation controller and in order for it to work with “& validate” I need to inject it like this:


and this works fine.

Topic here why this is needed:

However I am now trying to do this with autoinject. I added:

aurelia.use.transient(CustomValidationController, () => NewInstance.of(CustomValidationController).as(ValidationController));

in my main.js file but it’s not working.

I also tried to use “.key” and “.asKey” but same result. I get the “A ValidationController has not been registered.” error.

Any ideas?


Honestly, I don’t know what does, but try using container:

aurelia.container.registerTransient( CustomValidationController );

And probably this will be exactly what you want:

aurelia.container.registerTransient( ValidationController, CustomValidationController );

Now when you try to autoinject ValidationController, you get a new instance of CustomValidationController.