angularjs - TypeError: Cannot read property '0' of null (Javascript/Angular) -
i'm running relatively strange error here.
in controller, have array defined.
$scope.results = [];
on ng-keyup event, fire method:
$scope.search = function() { myservice.findstuff($scope.mymodel.searchterms).success(function(response) { $scope.results = response; });
on first keyup, search fires, returns result, , updates dom results:
<div ng-repeat="thing in results">{{ thing.name }}</div>
everything work perfectly, on first keypress.
afterwards, i'm getting error:
typeerror: cannot read property '0' of null
this crashes angular app , i'm out lunch.
edit: should clarify, error thrown before of code in $scope.search
executes. no query server fired, no console logging executed, nothing.
i've tracked down $scope.results = response;
. line removed, queries repeatedly fire no issue. i've noticed if try change results manually (ie. on keypress $scope.results = [{ name: "spaz" }]
, works on initial firing not on subsequent firings.
i'm going nuts! what's up?!