# Register Transient and AutoInject

**URL:** <https://discourse.aurelia.io/t/register-transient-and-autoinject/675>\
**Category:** Help Requests\
**Created:** [January 20, 2018, 7:40pm UTC](https://discourse.aurelia.io/t/register-transient-and-autoinject/675 "2018-01-20T19:40:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![d-kostov-dev](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/d-kostov-dev/32/495_2.png) [@d-kostov-dev](https://discourse.aurelia.io/u/d-kostov-dev)\
**Post date:** [January 20, 2018, 7:40pm UTC](https://discourse.aurelia.io/t/register-transient-and-autoinject/675/1 "2018-01-20T19:40:25Z")

</div>

Hi.

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

`@inject(NewInstance.of(CustomValidationController).as(ValidationController))`

and this works fine.

Topic here why this is needed: [https://github.com/aurelia/validation/issues/469](https://github.com/aurelia/validation/issues/469)

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?

Thanks.

---

<div class="post-metadata">

**Author:** ![tomasbonco](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/tomasbonco/32/35_2.png) [@tomasbonco](https://discourse.aurelia.io/u/tomasbonco)\
**Post date:** [January 22, 2018, 2:43pm UTC](https://discourse.aurelia.io/t/register-transient-and-autoinject/675/2 "2018-01-22T14:43:38Z")

</div>

Honestly, I don’t know what [NewInstance.as](http://NewInstance.as) does, but try using container:

```auto
aurelia.container.registerTransient( CustomValidationController );

```

And probably this will be exactly what you want:

```auto
aurelia.container.registerTransient( ValidationController, CustomValidationController );

```

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