Currently, I am attempting to apply a $filter
to an array that is populating ng-repeat
from the controller. This particular array defines the contents of "list" for ng-repeat="l in list"
.
Is there a way to achieve something like this?
var sidePanelFilter = $filter('sidePanel');
if (condition) {
var numArray = myService.items;
$scope.list = sidePanelFilter(numArray);
}
This is how my HTML looks:
<li ng-repeat="l in list | orderBy track by $index">
{{ l }}
</li>
I am looking to set the $filter
in the controller so that I can dynamically generate the list
. It is important for me to keep the array's contents intact without making any changes.
Edit
I have created a codepen that showcases the issue I'm facing.