Reputation: 838
What I want to achieve:
highlight some text in p element
(not add/ or remove) paper-badge when value is 0
change paper-badge color depending on number
Sample module to play with:
<link rel="import" href="https://polygit2.appspot.com/components/polymer/polymer.html">
<link rel="import" href="https://polygit2.appspot.com/components/iron-icons/communication-icons.html">
<link rel="import" href="https://polygit2.appspot.com/components/paper-icon-button/paper-icon-button.html">
<link rel="import" href="https://polygit2.appspot.com/components/paper-badge/paper-badge.html">
<dom-module id="question-one">
<template>
<template is="dom-repeat" items="{{numbers}}">
<p>color one of my letters</p>
<paper-icon-button id="someid{{index}}" icon="communication:email"></paper-icon-button>
<paper-badge for="someid{{index}}" label="{{item}}"> </paper-badge>
</template>
</template>
<script>
Polymer({
is: "question-one",
properties: {
numbers: {
type: Array,
value: function () {
return [0, 1, 2, 0, 4, 5, 0, 7, 8, 0]
}
}
}
}); </script>
</dom-module>
and usage:
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://polygit2.appspot.com/components/webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="questions//question-one.html" />
</head>
<body>
<question-one></question-one>
</body>
</html>
Upvotes: 0
Views: 615
Reputation: 658067
Add an id
attribute
<p id="someId">
use the $
map to get a reference to the element
this.$.someId.innerText...
this.$
doesn't work for dynamically added HTML or HTML inside template is="dom-if" or
template is="dom-repeat" or similar.
For such cases you can use this.$$(selector)
where all CSS selectors are supported, while this.$...
only supports id
(without #
)
Upvotes: 3