Referencing DOM nodes in Angular expressions is disallowed

5,618 views
Skip to first unread message

Martin Halamíček

unread,
Oct 16, 2013, 9:25:52 AM10/16/13
to ang...@googlegroups.com
Some of my directives became broken after upgrade to Angular v1.2.0-rc.3

Throws an error "[$parse:isecdom] Referencing DOM nodes in Angular expressions is disallowed! Expression: submit()" on line 31.

I found workaround using $timeout but it is quite hacky.

It is not longer supported to access DOM in directives? How i should handle it now?

thanks
Martin

spint

unread,
Oct 17, 2013, 3:03:25 AM10/17/13
to ang...@googlegroups.com
We are experiencing the same issue all over our application after upgrading from RC2 :s
Any thoughts on this ?

KR
Stijn

Majid Burney

unread,
Oct 17, 2013, 4:36:50 AM10/17/13
to ang...@googlegroups.com
They've only disallowed accessing DOM nodes in expressions, not in directives. Your code is only broken because of Coffeescript's bad habit of automatically returning the last value in a function's scope. Angular detects that the function has returned a DOM node and throws an exception to keep you safe. Add an explicit "return" to the end of each of those functions and they should work fine.

spint

unread,
Oct 17, 2013, 4:59:41 AM10/17/13
to ang...@googlegroups.com
Thanks man, that solved it for me, you saved my day :-) 

Apoorv Parijat

unread,
Dec 3, 2013, 12:15:36 AM12/3/13
to ang...@googlegroups.com
Saved my day!!

Pierre Maoui

unread,
Jan 30, 2014, 9:52:42 AM1/30/14
to ang...@googlegroups.com
Amazing to notice this. Thanks ! 

Nik

unread,
Feb 19, 2014, 11:16:02 AM2/19/14
to ang...@googlegroups.com
You saved the day for me,too


On Thursday, October 17, 2013 10:36:50 AM UTC+2, Majid Burney wrote:

Giovanni K Bonetti

unread,
Mar 14, 2014, 6:02:38 PM3/14/14
to ang...@googlegroups.com
Mine too!

Xingyi Chen

unread,
Mar 18, 2014, 6:03:34 AM3/18/14
to ang...@googlegroups.com
Mine too!!

Arvid Kahl

unread,
Mar 21, 2014, 8:15:54 PM3/21/14
to ang...@googlegroups.com
And mine!

Ken Wang

unread,
Apr 11, 2014, 3:53:35 PM4/11/14
to ang...@googlegroups.com
Thank you so much Majid!

Eric Miller

unread,
Apr 23, 2014, 4:43:20 PM4/23/14
to ang...@googlegroups.com
Nice! I had no idea why it was failing. Not sure I'd call auto returning a bad habit. In many cases it makes my code shorter and easier to read, especially with angular where I'm always returning functions or objects to the framework.

I put the onus on Angular for a clearer error message. I thought it was detecting the access of a dom node, since that's what the documentation said, not the return type of a function.


On Thursday, October 17, 2013 1:36:50 AM UTC-7, Majid Burney wrote:

Roy Truelove

unread,
May 23, 2014, 3:41:05 PM5/23/14
to ang...@googlegroups.com
My day was likewise saved by this answer
Reply all
Reply to author
Forward
0 new messages