# Where is this.value defined

**URL:** <https://discourse.aurelia.io/t/where-is-this-value-defined/3165>\
**Category:** Help Requests\
**Created:** [January 17, 2020, 3:03pm UTC](https://discourse.aurelia.io/t/where-is-this-value-defined/3165 "2020-01-17T15:03:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![elmt1](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/elmt1/32/2687_2.png) [@elmt1](https://discourse.aurelia.io/u/elmt1)\
**Post date:** [January 17, 2020, 3:03pm UTC](https://discourse.aurelia.io/t/where-is-this-value-defined/3165/1 "2020-01-17T15:03:40Z")

</div>

I have a custom attribute and ran into a problem using something like custom-attribute="${index}" where the value in the elements attributes array was "{$index}". I figured out that I could simply use this.value in the custom attribute to get the resolved value, but I get a typescript error because this.value isn’t defined. What should my class extend to pick up the definition of this.value? I think my code matches the [Custom Attributes Documentation](https://aurelia.io/docs/templating/custom-attributes#explicit-attribute-naming) fairly closely.

Thanks!

---

<div class="post-metadata">

**Author:** ![Sayan751](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/sayan751/32/1861_2.png) [@Sayan751](https://discourse.aurelia.io/u/Sayan751)\
**Post date:** [January 17, 2020, 3:53pm UTC](https://discourse.aurelia.io/t/where-is-this-value-defined/3165/2 "2020-01-17T15:53:00Z")

</div>

I think it is always better to have `@bindable value;` defined explicitly in your TS code.

---

<div class="post-metadata">

**Author:** ![elmt1](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/elmt1/32/2687_2.png) [@elmt1](https://discourse.aurelia.io/u/elmt1)\
**Post date:** [January 17, 2020, 4:41pm UTC](https://discourse.aurelia.io/t/where-is-this-value-defined/3165/3 "2020-01-17T16:41:23Z")

</div>

Thank you @Sayan751, I had tried using explicit binding but I never I seem to get a value when I have something like “element-id: ${‘something’ + $index}”. I tried several variations of that. It could just be the syntax I was using was off, but I came across [issue 136](https://github.com/aurelia/templating-binding/issues/136), which made me think it wouldn’t work. Using this.value is OK in my case, because I only have one value I care about, which is the id of the element it should act upon.

---

<div class="post-metadata">

**Author:** ![zewa666](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/zewa666/32/19_2.png) [@zewa666](https://discourse.aurelia.io/u/zewa666)\
**Post date:** [January 18, 2020, 5:49am UTC](https://discourse.aurelia.io/t/where-is-this-value-defined/3165/4 "2020-01-18T05:49:48Z")

</div>

Due to the dynamic nature of JS you can assign props on the fly. TS on the other hand prefers your VM to be typed in order to pevent mistakes. The same applies for the ref attribute to get hold of the targets element. In your VM simply declare at the begin of your class `public value: string` or whatever type you expect. Since the value comes from the View the property should be public

---

<div class="post-metadata">

**Author:** ![elmt1](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/elmt1/32/2687_2.png) [@elmt1](https://discourse.aurelia.io/u/elmt1)\
**Post date:** [January 18, 2020, 8:15pm UTC](https://discourse.aurelia.io/t/where-is-this-value-defined/3165/5 "2020-01-18T20:15:39Z")

</div>

Thank you @zewa666, that got rid of the error. I thought I was missing something, since from my codes perspective this.value is something that I get, but I don’t know what defines it.
