You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Alpha35: Empty event expression produce cryptic error #3754
On alpha 33 it worked great.
On alpha35 it produces the following runtime error:
EXCEPTION: TypeError: Cannot set property 'lastInBinding' of undefined
angular2.js:13030 STACKTRACE:
angular2.js:13030 TypeError: Cannot set property 'lastInBinding' of undefined
at Function.execute._ConvertAstIntoProtoRecords.create (http://localhost:5555/lib/angular2.js:18104:47)
at http://localhost:5555/lib/angular2.js:17730:49
at Array.map (native)
at createEventRecords (http://localhost:5555/lib/angular2.js:17729:36)
at JitProtoChangeDetector.execute.JitProtoChangeDetector._createFactory (http://localhost:5555/lib/angular2.js:17575:39)
at new JitProtoChangeDetector (http://localhost:5555/lib/angular2.js:17567:32)
at $__1.execute.JitChangeDetection.createProtoChangeDetector (http://localhost:5555/lib/angular2.js:10323:20)
at http://localhost:5555/lib/angular2.js:15553:42
at Array.map (native)
at Function.execute.ListWrapper.map (http://localhost:5555/lib/angular2.js:6374:26)
The following modification still produces the error:
@cghislai apart from the regression (?) that you are seeing here- what would be the case for having an empty event handler? I mean - if you don't take any action on a given event, why adding (fileread) at all?
I would say that in this case we should simply throw a good error, but maybe you've got a valid use-case?
It was an hack.
I had a filereader that read the file then stored the dataURI in a field. I had an img component with the src attributed bound to that dataURI field. The issue was that the img was not reloaded once the file was read. Triggering that event triggered change detection and the image was updated.
I now moved that job in a Promise, and update the dataURI field in the then clause, and image updates automatically.
In earlier versions I was using this "hack" to trigger change detection based on events. Now I can't do this anymore unless I would like to update my directive model, which sometimes I might don't want to when working with simple view locals.
@pkozlowski-opensource I actually agree that <input #var (keyup)> is a desirable feature, not a hack. It indicates "This event is meaningful to my component" even if the component itself has no code to run for the event. I think forcing a pattern where people write (keyup)="noopHandler()" with an empty function in the component is more of a hack.
Note that <input (keyup)="null"> does work currently.
It indicates "This event is meaningful to my component" even if the component itself has no code to run for the event.
Why it would be meaningful to a component if no code is executed in response? Do you have a use-case where this pattern would be an elegant solution? All the use-cases I've seen so far involved repeated reading from the DOM and I don't think we want to encourage it.
Note that <input (keyup)="null"> does work currently.
This is why I was saying that we should throw :-)
Personally I don't mind if we support this or not, but I'm afraid of promoting a pattern that involves reading from the DOM all the time.
I understand you guys are already on it, but, regardless of what you decide, the current error message, coupled with the tutorial, is very misleading - bad, specially for those first trying the new version.
Activity
pkozlowski-opensource commentedon Aug 20, 2015
@cghislai apart from the regression (?) that you are seeing here- what would be the case for having an empty event handler? I mean - if you don't take any action on a given event, why adding
(fileread)at all?I would say that in this case we should simply throw a good error, but maybe you've got a valid use-case?
cghislai commentedon Aug 20, 2015
It was an hack.
I had a filereader that read the file then stored the dataURI in a field. I had an img component with the src attributed bound to that dataURI field. The issue was that the img was not reloaded once the file was read. Triggering that event triggered change detection and the image was updated.
I now moved that job in a Promise, and update the dataURI field in the then clause, and image updates automatically.
pkozlowski-opensource commentedon Aug 20, 2015
OK, so from what I understand it was simply a way of hacky way of kicking-off change detection, right?
If so, let's solve this issue by introducing better checks / error messages for missing event handlers. How does it sound?
cghislai commentedon Aug 20, 2015
Sounds good. That was the main point of this issue.
LinboLen commentedon Aug 26, 2015
It sames execute _ConvertAstIntoProtoRecords.create, rec is still empty array
its append first, but some ast visit execute nothing,such as
ASTWithSourcegionkunz commentedon Sep 16, 2015
So how would we go about specifying where we need change detection? Working with simple view locals this can be very handy:
In earlier versions I was using this "hack" to trigger change detection based on events. Now I can't do this anymore unless I would like to update my directive model, which sometimes I might don't want to when working with simple view locals.
Is there an other best practice I'm missing here?
Cheers
2 remaining items
pkozlowski-opensource commentedon Sep 17, 2015
Right - we should definitively update examples then.
alxhub commentedon Nov 20, 2015
@pkozlowski-opensource I actually agree that
<input #var (keyup)>is a desirable feature, not a hack. It indicates "This event is meaningful to my component" even if the component itself has no code to run for the event. I think forcing a pattern where people write(keyup)="noopHandler()"with an empty function in the component is more of a hack.Note that
<input (keyup)="null">does work currently.pkozlowski-opensource commentedon Nov 20, 2015
@alxhub
Why it would be meaningful to a component if no code is executed in response? Do you have a use-case where this pattern would be an elegant solution? All the use-cases I've seen so far involved repeated reading from the DOM and I don't think we want to encourage it.
This is why I was saying that we should throw :-)
Personally I don't mind if we support this or not, but I'm afraid of promoting a pattern that involves reading from the DOM all the time.
acdcjunior commentedon Feb 7, 2016
+1
I got the same error:
EXCEPTION: TypeError: Cannot set property 'lastInBinding' of undefinedat beta.3 while trying out the very same example from https://angular.io/docs/js/latest/guide/user-input.html#local-variables .I understand you guys are already on it, but, regardless of what you decide, the current error message, coupled with the tutorial, is very misleading - bad, specially for those first trying the new version.
zamrokk commentedon Mar 24, 2016
👍 this still exists on beta-9
johnarchuletta commentedon May 7, 2016
This error is still occuring in RC1 when using something like
<a (click)></a>).(Forgot to add handler to an anchor element and Chrome spit this out)
JohannesAtGit commentedon Jul 28, 2016
Error still occuring in RC4 when using
(click)=""fix(TemplateParser): report empty expression (#10391)
angular-automatic-lock-bot commentedon Sep 9, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.