1

I'm building a menu with a dom-repeat template like this:

        <template is="dom-repeat" items="{{appletsMenu}}">
              <a data-route="{{item.dataRoute}}" href="{{item.href}}">
                <iron-icon icon="{{item.icon}}" src="{{item.iconSrc}}" ></iron-icon>
                <span>{{item.name}}</span>
              </a>
        </template>

The data-route attribute is not filled though in the generated DOM:

<a href="...">...</a>
<a href="...">...</a>

It seems that the template only renders "normal" attributes like href. Am I'm missing something? Thanks.

1

1 Answer 1

2

To bind to an attribute, use $= rather than =. This results in a call to:

element.setAttribute(attr, value);

As opposed to:

element.property = value;

(source)

So in your case:

<a data-route$="{{item.dataRoute}}" href="{{item.href}}">
Sign up to request clarification or add additional context in comments.

Comments

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.