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 fairly closely.
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, 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.
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
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.