在dart聚合物0.9.5中打破的程序化定制元素?

时间:2014-03-18 13:38:04

标签: dart dart-polymer polymer

聚合物0.8.5中用于编程自定义元素创建的earlier solution似乎在聚合物0.9.5中被打破。

如果我们修改standard click-counter example以使用程序化元素创建,如下所示:

main() {
  Logger.root.level = Level.ALL;
  Logger.root.onRecord.listen((LogRecord rec) {   
    print('${rec.loggerName}: ${rec.level.name}: ${rec.time}: ${rec.message}');
  });

  initPolymer();

  var clickCounter = new Element.tag('click-counter');     
  document.body.children.add(clickCounter);
}

点击事件 正确调用{{increment}}方法,但{{count}}值未在HTML中更新。

1 个答案:

答案 0 :(得分:3)

聚合物代码应该从

运行
import "package:polymer/polymer.dart";

main() {
  initPolymer().run(() {
    // code here works most of the time
    Polymer.onReady.then((value) {     
      // some things must wait until onReady callback is called
      // for an example look at the discussion linked below
    });
  });
}

simple tooltip working in dartium, not as javascript