Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binding functions with attributes

Is there a way to bind functions with attributes, something like this:

<a _href="{{go('login')}}">Login</a>

then

String go(String routePath) {
  // Returns url for login
}
like image 259
Miguel Fermin Avatar asked Apr 28 '26 13:04

Miguel Fermin


1 Answers

For routing task, you may bind using additional attribute for path:

<a route="/api/login" on-tap="{{go}}">

and then, in your go function:

void go(Event e, var detail, Element sender) {
  e.preventDefault();
  fire('change-route', detail: sender.attributes['route'] );
}
like image 57
Mike Avatar answered Apr 30 '26 06:04

Mike



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!