Can someone please provide an example of proper implementation of dom-if
?
No example of proper usage is provided by the official documentation. (Sorry there is no direct link. Must use menu in upper left and select dom-if
).
Here is what I have so far. Obviously, it is not working.
<template>
...
<template is="dom-if" if="{{action}}=='Login'">
<!-- Also tried: if="{{action=='Login'}}" -->
<a href="#">Forgot password?</a>
</template>
...
</template>
It's cumbersome, but you have to do this:
<template is="dom-if" if="[[_actionIsLogin(action)]]">
<a href="#">Forgot password?</a>
</template>
<script>
Polymer({
...
_actionIsLogin: function(action) {
return action === 'Login';
}
...
});
</script>
Explicitly create a function that returns either true
or false
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With