Search code examples
polymerpolymer-1.0polymer-starter-kit

Passing attribute to custom element in Polymer as a function


I'm trying to do something really simple in Polymer. I'm trying to pass an attribute using a function.

<dom-module id="my-fixtures">
    <template>
        <fixtures-list fromdate="[[_requiredDay(24)]]"></fixtures-list>
    </template>
    <script>
        Polymer({
            is : 'my-fixtures',
            properties: {
                fromdate: String
            },
            _requiredDay: function (offset) {
                // 1 day before now
                var d = new Date(new Date().getTime() - parseInt(offset) * 60 * 60 * 1000); 
                var n = d.toJSON();
                return n;
            }
        });
    </script>
</dom-module>

But it' not working. If I change the function for a static srting value it works. Any help?

Thanks


Solution

  • The fromdate property should be on fixtures-list not on my-fixtures

    https://jsbin.com/jucevujeyo/edit?html,console,output