我想使用模板绑定传递函数/方法引用。这应该工作吗?我究竟做错了什么?
索引.dart
@observable
class Model() {
onSignOutCallback(message) {
print(message);
}
}
main() {
query("#tmpl").xtag.model = new Model();
TemplateElement t = query("#plus-login-tmpl") as TemplateElement;
t.bindingDelegate = new PolymerExpressions();
}
索引.html
……
my_component.html
<polymer-element name="my-component" attributes="sign-out-callback">
<button on-click="{{signOutCallback}}>Sign out</span>
</polymer-element>
my_component.dart
typedef void OnSignOutCallback(message);
@CustomTag("my-component")
class MyComponent extends PolymerElement with ObservableMixin {
OnSignOutCallback onSignOutCallback;
@override
inserted() {
super.inserted();
onSignOutCallback("signed out"); // test if value was assigned
}
}