Search code examples
dartdart-polymerpolymer

Pass parameters to Dart Polymer element


The only solid example I could find for Dart Polymer doesn't use any parameters. How can I pass parameters to the template. Is it done through the constructor?

My specific example is that I have a card element with a title, and I want to pass the title of the card as a string to the element.

I have looked at Passing data to a Polymer element

but this is not exactly what I want to do. I want to pass data from within dart code.


Solution

  • The constructor of elements is called from Polymer and there is no way to pass parameters.

    You can as @Vloz wrote, assign values after the element was created or you can use binding as in the question you linked (Passing data to a Polymer element) using bindings.