I know this is just a small error somewhere, but I can't spot it. I've been
playing around with the code at this fiddle, http://jsfiddle.net/SAWsA/11/,
trying to learn angular. The code worked quite well, after a few fixes were
made to it. I then added in a get, to pull the data from a json file, and
the search function no longer works. The loop under the search exits, after
the first iteration, and I just can't figure out why. I've been pulling my
hair out over this for a couple of hours now, and I can't find any relevant
information via the internet. Here is the code, I feel, is causing the
problem.
var searchMatch = function (list, item) {
if (!item) {
return true;
}
return list.toLowerCase().indexOf(item.toLowerCase()) !== -1;
};
// init the filtered items
$scope.search = function () {
$scope.filteredItems = $filter('filter')($scope.itemList, function
(item) {
console.log(item);
for(var prop in item){ //***Here is the escaping loop.
if (item.hasOwnProperty(prop)) {
console.log(prop + " -> " + item[prop]);
if( searchMatch(item[prop], $scope.query) ){
return true;
}
}
}
return false;
});
Any help would be greatly appreciated. If you need more information to help
me solve this problem, just let me know. This is really starting to get me.
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.