I\'m trying to instantiate a Polymer element in my Dart code.
Here\'s my element:
@CustomTag(
I don't know what exactly you mean by "to access the values of my component by their accessors (instead of by attributes of HtmlElement)"
(new Element.tag('card-component') as CardComponent)
..playerName = 'blabla';
adding a custom factory constructor allows you to use the element as if it had a normal constructor
@CustomTag('card-component')
class CardComponent extends PolymerElement {
@published
String playerName;
CardComponent.created() : super.created();
factory CardComponent CardComponent() {
return new Element.tag('card-component');
}
}
var cc = new CardComponent()..playerName = 'blabla';
If you want to do this from main() not from within another component, ensure that main() contains the Polymer (initialization code why am I getting type error on polymer.dart element?, how to implement a main function in polymer apps)