Weird error when using $


I’m doing a simple search and filter on an array counting around 150 objects.

$ = function(){
    $scope.airports = "";
    var filtered ={
      var str = $,
        test =;
      return RegExp('^'+str).test(test);
    $scope.airports = filtered;

in about 40% of times I’m getting the following error:
undefined is not an object (evaluating ‘elm.nodeType’)

Error: undefined is not an object (evaluating 'elm.nodeType')

can anyone point me what it could be?


Same deal for me, I’m hitting this as well and can’t figure it out. It seems to happen randomly, and the stack-trace gives no clues.


OK, I’m not sure if your error is the same as mine since I can’t see your HTML, but in my case I had an ng-repeat that was using track by index. Once I changed that to track by everything was fine.


You should take care of checking in the view that the variable (array in this case) is not in an inconsistent state. Because it seems that is something about events cancelled and the digest cicle. Maybe in that 40% of times you’re refreshing the view by two differents actions/event handlers? Anyways, if you’re updating $scope.airports in your view and also accessing it’s elements after a search() function, try checking for the existence of airports in your view, > because undefined is not an object :wink:

What i mean:

<div **ng-if="airports"** ng-repeat="airport in airports...">