Reputation: 6595
Would like to achieve this without using a helper function as shown here. I know I can use some basic operators (i.e. !
), but would like to use a bit more logic in templating. Basically the aim is to use the Boolean value set via iron-media-query
to toggle a class on an element.
Pseudo code:
<div class$="[[(mobile)?'mobile-styling':null]]"></div>
P.S. the class name cannot be the boolean variable name.
Thanks
Upvotes: 0
Views: 862
Reputation: 10916
Unfortunately this feature has been deprecated for performance improvements. polymer 1.0+ only support the following:
here is an example for how you can achieve computed binding:
<dom-module ...>
<template>
<div class$="[[hasMobileStyle(mobile)]]"></div>
</template>
<script>
Polymer({
...
hasMobileStyle: function(mobile) {
return mobile ? 'mobile-styling' : '';
}
});
<script>
</dom-module>
you can also use the boolean as a selector to get rid of the computed binding:
<div class$="mobile-styling--[[mobile]]"></div>
and you'd do a selector on .mobile-styling--true
What you are asking for cannot be done. only the three conditions work, [[(mobile)?'mobile-styling':null]]
does not fit the criteria.
Upvotes: 1