Programmatically create special Polymer-Element Programmatically create special Polymer-Element dart dart

Programmatically create special Polymer-Element


As of polymer 0.8.5 you can use constructor like

new Element.tag('tag-bar');

also, no more .xtag and no more .host (host == this now)

credits go to Seth Ladd who explained this on polymer mailing list


Note: this only works for polymer.dart < 0.8.5. See other answer for the new way.

Custom elements don't really have constructors like we're familiar with them in Dart. Instead, try this:

var tabBar = createElement('tag-bar');tabBar.xtag.items = toObservable(['a','b','c']);query('body').children.add(tabBar);