Function references
In Aurelia, you can use the .call
binding command to invoke functions directly from your view. This is particularly useful when you need to pass specific arguments or control the context in which the function is called.
How It Works
When you use .call
, Aurelia will:
Evaluate the expression in the context of your view-model
Invoke the resulting function with the provided arguments
Set the function's
this
context to the view-model
Examples
Basic usage
Passing Event Object
You can pass the event object using $event
:
Tips
Use
.call
when you need to pass specific arguments to your function.It's great for one-time function calls that don't need to update bindings.
Remember,
.call
doesn't create a persistent binding like.bind
does.
Last updated
Was this helpful?