Angular interpolation in HTML attribute "name"

<input type="radio" name="{{foo}}" formControlName="{{foo}}">

 

IntelliJ understands, that {{foo}} is an interpolation in the formControlName-attribute.

But in the name attribute it does not. It thinks, that {{foo}} is an array and that I am missing a : Like in {foo : bar}.

The code compiles just fine, is this an IntelliJ-Bug?

 

0
6 comments

can't reproduce with similar syntax. Screenshot shows that there is some language injected in this attribute. Please check custom injections in Settings | Editor | Language Injections - all injections with IDE and Project scope are custom ones - do you have any? Also, please put cursor within name attribute value and hit Alt+Enter - what menu can you see?

1
Avatar
Permanently deleted user

I opened Settings | Editor | Language Injections. Everything is "build-in", no IDE or Project Scope. No Cusoum ones.

 

 

Screenshot of the Alt+Enter:

 

As you can see in the screenshot I used a workaround with property binding since

name="{{foo}}" <=> [name]="foo"

 

That worked, but the interpolation in attributes should work as well...

0

can you share a sample project/files the issue can be reproduced with plus your idea.log (Help > Show log in ...)?

0
Avatar
Permanently deleted user

Very Strange. I just copied the code in a new project to create a sample, there it works just fine.

 

The log is here:

https://filebin.net/axz6c4pg09ehmc7r

0

it works fine for me as well... that's why I've asked for a project.

BTW, does the issue persist after caches invalidation (File > Invalidate caches, Invalidate and restart)?

0
Avatar
Permanently deleted user

Yes, the issue persists. 

I just copied the whole .html and .ts File to a new project, it just works fine there. It recognised angular and everything. So something must be broken inside my settings for that project, it is not an IntelliJ-Bug.

But since the property binding workaround works just fine for me lets leave it there. Thank you for your help :)

 

/closed

0

Please sign in to leave a comment.