Referencing DOM nodes in Angular expressions is disallowed!
June 02, 2014
Adding to the list of more Angular quirks, I stumbled on this error:
Referencing DOM nodes in Angular expressions is disallowed!
When having a callback to an ng-click
that removes a class from a DOM element:
onClick = ->
element.removeClass 'some-class'
The fix? Similar to the post referenced above, just return something other than the function call:
onClick = ->
element.removeClass 'some-class'
return
Side note: Isn’t that a rather scolding error message? It’s like getting yelled at for pushing someone on the playground.
Hey, I'm Ian. I build websites and write about what I learn as I go. Follow me on Twitter.