I am learning angular.js and trying to determine what the easiest way would be for me would be to display message 'no values found' when array is empty.
I have tried this which is not working
<ul>
<li ng-show="!items.length">No values</li>
<li ng-repeat="i in items | searchFor:searchString">
<p>{{i.title}}</p>
</li>
</ul>
And my controller
app.filter('searchFor', function () {
return function (arr, searchString) {
if (!searchString) {
return arr;
}
var result = [];
searchString = searchString.toLowerCase();
angular.forEach(arr, function (item) {
if (item.title.toLowerCase().indexOf(searchString) !== -1) {
result.push(item);
}
});
console.log(result.length);
return result;
}
});
How could I display the message 'No values found' when there are no values returned?