I created a custom component that basically wraps a d3 line chart. Now I want to be able to register a callback for clicks on the rows in the diagram.
I gave the component a @NgCallbackparameter, which then dispatches events:
class NetworkSummaryComponent implements NgShadowRootAware {
@NgCallback('callback')
Function callback;
void onShadowRoot(ShadowRoot shadowRoot) {
...
chart.callMethod('listen', ['line-click', (ev) {
var name = ev.callMethod('getLineName');
print(name);
callback({'name': name});
}]);
}
}
When using the component, I define the function of my controller as a callback:
<network-summary
...
callback="ctrl.lineClicked">
</network-summary>
However, this function is never called, I suppose I know that the callback comes from JS because it prints in the first fragment.
If you instead specify the attribute as callback="ctrl.lineClicked()", I get a strange exception:
Closure call with mismatched arguments: function 'call'
I could not find the official documentation on how to make callbacks correctly, so I'm not quite sure what I'm doing wrong. Any ideas?