dom-if
template does not work. I have the following polymer 2 component:
<link rel="import" href="../bower_components/polymer/polymer-element.html">
<dom-module id="ohr-block">
<template>
<style>
:host {
display: block;
}
</style>
<h3>[[mydata.title]] [[_isType('one')]]</h3>
<template is="dom-if" if="[[_isType('one')]]"> <!-- problem is here -->
<div>Should be displayed</div>
</template>
</template>
<script>
/**
* @customElement
* @polymer
*/
class OhrBlock extends Polymer.Element {
static get is() { return 'ohr-block'; }
static get properties() {
return {
mydata: {
type: Object,
value: {"title": "my title", "type" : "one"}
}
};
}
_isType(type) {
return this.mydata.type === type;
}
}
window.customElements.define(OhrBlock.is, OhrBlock);
</script>
</dom-module>
As you can see, I am using [[_isType('one')]]
inside h3
html tag. In this place it is working and I can see true
but when I use [[_isType('one')]]
like condition into if
attribute it does not work and template content is not showed.
The problem is I have not imported dom-if
<link rel="import" href="../bower_components/polymer/lib/elements/dom-if.html">