Programmatically create special Polymer-Element

那年仲夏 提交于 2019-12-05 19:42:46
tomaszkubacki

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);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!