-
Notifications
You must be signed in to change notification settings - Fork 232
Template syntax should support tear-offs for event bindings #506
Comments
Open question: would we handle |
I'm a fan of inferring based on a variable/lack-of. WDUT @hterkelsen? |
If that's too hard to land off the bat, we could start with one and then add support for inference. Also, should we block this on the angular_ast integration? |
Probably. /cc @MichaelRFairhurst @mk13 |
What about something like this?
and in the tpl
And what about
in short, this requires more specification. And I'm seeing a lot of surprising edge cases that will exist in any spec. Its kind of like if dart suddenly added support for
Yes, practically you can look at that and figure out how this could be a tearoff....but the theory gets mucky and so its probably better to change the syntax
what about
? Though then we're getting back into some of the problems that pipe expressions had, where we're deviating from dart expression syntax which causes its own problems. I like the idea of this. I'm hoping there's a more precise way to specify it. |
As long as we're throwing ideas out there... Off the top of my head, there are only two uses for the current template syntax for calling methods.
Everything else, like passing literals can be done from the controller. What if there was a annotation like <div *ngFor="let foo of foos">
<button (click)="handleFoo">Click Me</button>
</div> @Handle(/*...some additional information maybe needed here */)
void handleFoo(Event event, Foo foo) {
/// Do some stuff.
} I'm not sure what information would be required. maybe the types would get you far enough, or maybe you would need the names of the locals. (As a side note, my ulterior motive is I want a template syntax where dart expressions aren't required.) |
I like the original idea, but if it requires additional Angular syntax, I think it's not worth it. |
@jonahwilliams there is another case. Passing a varref from a template directive: |
This is now in #1437! |
I haven't landed #1437 yet, so shouldn't we keep this open until then? The PR has a comment that will auto close this when landed. |
#1437 is now synced in d72bcef? @alorenzen |
Oopps, sorry. I had a CL pending from before vacay, but forgot that it's a fix for this, not the PR itself. Yes, this can be closed. |
Right now, we have to supply a method call for template bindings, using the magical
$event
variable.<material-button (trigger)="onClick($event)"></material-button>
In order to be more "dart-y", and also to remove the need to remember the magic
$event
variable, we could instead support a tear-off<material-button (trigger)="onClick"></material-button>
The text was updated successfully, but these errors were encountered: