Call binding with parameters

According to this issue .call() binding should allow passing arguments · Issue #271 · aurelia/binding · GitHub, in Aurelia v1 you could pass parameters in call binding by invoking with an object with named values, and these are used on actual callback.

For example using call binding expecting to get value “param”

<my-element callback.call="onCallback(param)" />

and one is provided in invocation

this.callback({param: some_value});

But this does not seem to work in Aurelia 2, the callback is invoked but no params are passed to the callback function.

Example gist: Dumber Gist : Custom element invokes callback with a value incremented on each click.

Has this changed in Aurelia 2?

So it seems it indeed has changed, did not spot this in migration notes: Migrating to Aurelia 2 - The Aurelia Docs.

Using “$event.param” instead does work, as can be seen in updated gist.

1 Like