In my controller, I am populating a list on the page. However, I need to exclude certain items from the list based on specific flags associated with them. To achieve this, I have created a simple function that returns a boolean value, which is then used in the ng-show directive to hide these particular items. The function is called multiple times within the ng-repeat block. My expectation is that if the array contains n elements, the function should be invoked n times unless there are changes in the array's contents or length.
<ul>
<li ng-repeat="item in items" ng-show="display(item)">{{item.name}}</li>
</ul>
The display function implemented like below:
display = function(item)
{
if(item.flag)
return true
else
return false;
}