0

My CSS

ol.progress[data-steps="9"] li { width: 11%; }

I want to use the above in my template like this:

<ol class="progress" data-steps=4>

   <li *ngFor..> </li>

I tried:

<ol class="progress" [data-steps]="myNg2Variable">

Get errors:

Template parse errors: Can't bind to 'data-steps' since it isn't a known native property

How to achieve?

1 Answer 1

1

You need to use the attr property with interpolation:

<ol class="progress" attr.data-steps="{{myNg2Variable}}">

Cheers

Sign up to request clarification or add additional context in comments.

1 Comment

you can also use "by value" notation <ol [attr.data-steps]="myNg2Variable">

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.