I am trying to write a function which filters rows based on couple of properties. When I run the code, the list is not getting displayed and there's an error stating "TypeError: Cannot read property 'name' of undefined ". I am trying to search on columns name and location. Here's my html code
<tbody ng-if="routerList.length">
<tr ng-repeat="router in routerList | orderBy: rule|filter : search | limitTo:5:5*(naviagtion.currentPage-1) ">
<td><span>{{router.routerId}}</span></td>
<td><span>{{router.name}}</span></td>
<td><span>{{router.macAddr}}</span></td>
<td><span>{{router.primaryIP}}</span></td>
<td><span>{{router.status}}</span></td>
<td><span>{{router.location}}</span></td>
</tr>
</tbody>
In my controller, I have a function search
$scope.search = function(item){
if($rootScope.naviagtion.searchText == undefined){
return true;
}else{
if(item.router.name.indexOf($rootScope.naviagtion.searchText) != -1 || item.router.location.indexOf($rootScope.naviagtion.searchText) != -1 ){
return true;
}
}
return false;
}
Can someone tell me what's wrong?
naviagtion.item.router. Can't read name cause .router is undefined?console.log(item)?