This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
ngRepeat should automatically or optionally render a fallback element when the expression yields no results #5919
Closed
Description
Say you have a complex expression on ngRepeat like:
<div ng-repeat="item in getItems() | filter:values">...</div>
So how can you detect if there are no items returned after the filter or from the getItems() call without using a scope variable/method? You would have to move everything into a controller.
Despite the repeat expression being complex and a potential bottleneck for an application, extracting the calculation out into a controller and manually watching the data set, filtering it and aggregating it is a lot of extra code after having just created a nice filtering system for your ngRepeat code.
What would be nice is if a fallback DIV was created only when the total (final) results extracted from the ngRepeat expression equal 0. This way you can do something like.
<div ng-repeat="item in getItems() | filter:values">
<div ng-repeat-empty>
There are no results found
</div>
</div>