angular icon indicating copy to clipboard operation
angular copied to clipboard

Error when calling renderer.setElementStyle, "TypeError: i is undefined"

Open scrapcupcake opened this issue 10 years ago • 5 comments

Steps to reproduce and a minimal demo of the problem RendererBugExample.zip

What steps should we try in your demo to see the problem? Launch live-server or similar, navigate to index. With the window focused, press any key

Current behavior EXCEPTION: Error during evaluation of "document:keyup" angular2.min.js:17:25209

ORIGINAL EXCEPTION: TypeError: i is undefined With a lengthy additional exception that would probably mostly be spam to paste here.

Expected/desired behavior Cursor is moved to absolute left 100px

Other information I was following the demo found here: http://juristr.com/blog/2016/01/learning-ng2-dynamic-styles/ in order to construct a simple demo of moving a square cursor around the screen; There may well be other, better ways of doing this, and I'm all ears, but regardless of resolving that issue, this behavior seemed like it needed reporting as a bug.

scrapcupcake avatar Apr 19 '16 18:04 scrapcupcake

A plunker would be great that demonstrates the issue.

zoechi avatar Apr 19 '16 18:04 zoechi

I think I figured it out: http://plnkr.co/edit/J57tSmVHai9KpsPQba25

scrapcupcake avatar Apr 19 '16 18:04 scrapcupcake

The error you're seeing Cannot read property 'boundElements' of undefined is because you're passing a nativeElement to the renderer and you're using beta.0. Renderer expects a nativeElement since beta.1. So you're making 3 mistakes : passing a nativeElement to the Renderer, you're using a really old beta, and you're asking for help where you're not supposed to. You'll get help faster if you follow the contributing guides

ericmartinezr avatar Apr 19 '16 18:04 ericmartinezr

Thank you for clarifying on the first two points.

I find the third to be rather missing my own additional info. I have read the contribution guidelines and thought I was following them.

This is my first time submitting an issue, I thought I had found a bug. I find it hard not be turned off of bothering to contribute further, given the warm reception my mistaken attempt received. I would reconsider the tone you apply to these sorts of messages in future.

And, because I feel my honor has been insulted, let me just say, I have solved my issue, and it took me all of five minutes to find after I understood the actually useful commentary you provided, after I had let my nerves subside from such needless abruptness.

The solution was to bind to [style.top] and [style.left], rather than using this more convoluted method, since I am using an element directive, not an attribute directive. I can and did find my own solution, and would have done so sooner, and simply apologized for a misreport and closed, had you not decided to rub it in my face.

scrapcupcake avatar Apr 19 '16 18:04 scrapcupcake

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.