If I understand what you are trying to do here, it’s as simple as passing the method to the child component and using it in the child component’s template.
New to 2.3, @ allows you to pass the function reference without executing it. Before this, the traditional approach would be to pass an object with the method like this:
i looked into your jsfiddle and i am a little confused
i made a jsbin example with your code and cleaned up some code.
first thing catches my eyes is:
your components attributes have to kebab-case. so click-method become clickMethod in the stache template
second:
you can dynamic bind on your click-method by using ($click)="{{clickMethod}}"
third:
you can specify your click method in the viewModel of our component. is you have the same the same method on the Map you commit to the main-template you can use click-method="../callMe"to use the parent scope.
fourth:
i used simpleHelper for stache, so text is passed as the value instead of a compute
pYr0x’s example of ($click)="{{clickMethod}}" works a charm but the following fails:
method: function(){
this.attr("clickMethod")();
}
Seems as though the actual click method that is part of the ‘parent’ view model is not available in the component’s view model. Perhaps I’d need to explicitly add the parent view model as I did in my contrived example; else just bind directly.