Here I would like explain that how to identify no records found in object or array of javascript with angularJS filters.

For that we have to find the length of search text in object if not found in object what we are trying to search.

Just we need to mention “Filter:searchText as Results“.

Here “Results” length helped to show the “no results found message”
ex: ng-if=”reults.length==0″ ->”no results found”

Here You can find complete example
+++++++++++++++++++++++++++++++++++++++++
<!doctype html>
<html lang=”en”>

<head>
<meta charset=”UTF-8″>
<title>AngularJS Filter with No Result Found Message if Resord is not in object</title>

<script src=”//ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js”></script>
<script>
app= angular.module(“myApp”,[]);
app.controller(“filterCtrl”,function($scope){

$scope.students=[{“Name”:”Madhu Bheemagani”},{“Name”:”Raju Pasunoori”},{“Name”:”Krisha Rao”},{“Name”:”Chinna Rao”}]

});

</script>

</head>
<body ng-app=”myApp”>
<div ng-controller=”filterCtrl”>
<input ng-model=”searchT” type=”text”><br>
<ul><li ng-repeat=”student in students | filter:searchT as Result”>{{student.Name}}</li>
<li ng-if=”Result.length==0″>No Result Found</li></ul>
</div>
</body>
</html>

Please share you thoughts….
AngularJS Filter with No Result Found Message if Resord is not in object

 

  • No Result Found

 

2670 Total Views 4 Views Today

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>