0

I have the following expression, which works:

<div class="circle" data-value="0.8">%</div>

when i'm trying to bind an attribute to it:

[data-value]="result/100"

I get the following error:

Can't bind to 'data-value' since it isn't a known property of 'div'.

Why and how it can be fixed?

1 Answer 1

4

Change <div class="circle" [data-value]="result/100">%</div> to

<div class="circle" [attr.data-value]="result/100">%</div>

or

<div class="circle" attr.data-value="{{result/100}}">%<div>
Sign up to request clarification or add additional context in comments.

1 Comment

Seems the last option doesn't work. It should be attr.data-value="{{result/100}}"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.