I want to set the attribute of the options object in my user element, which will take default values ββif they are not provided by the user.
<!DOCTYPE html> <html> <head> <script src="bower_components/platform/platform.js"></script> <link rel="import" href="bower_components/polymer/polymer.html"> </head> <body> <my-element options="{{{ option_1: 'val1', option_2: 'val2', allow_this: true, allow_that: false }}}"> </my-element> </body> </html> <polymer-element name="my-element" attributes="options"> <template> <ul> </ul> </template> <script> Polymer('my-element', { options: { option_1: 'default_val1', option_2: 'default_val2', allow_this: false, allow_that: false } }); </script> </polymer-element>
The above code does not work, because the values ββspecified in the element constructor always override the ones I'm trying to pass. How can I configure it so that the parameter values ββare set to those that were transferred, and the default values ββare used only as a fallback?
polymer
Peter
source share