Recently, I implemented an ngRepeat on a Map to iterate through "(key, value)" pairs. However, I encountered an issue where I needed to write a filter to restrict certain results. This filter was designed to accept two parameters. One parameter is passed in the ngRepeat call, so logically I should receive two parameters. The manually passed parameter is a boolean value. Upon inspecting the debugger, both parameters were set, with the second parameter being "true", as expected. Therefore, I anticipated the first parameter to correspond to my "(key, value)" pair. To my surprise, the first parameter returned an empty Object.
In my HTML code, the reference looks like this:
<div ng-repeat="(name, thing) in thingMap | limitThings:showOnlyFailed">
The "thingMap" functions as a map that uses the "name" property as keys and "thing" objects as values.
Below is my filter definition, outlining what I had initially thought the first parameter would contain:
thingModule.filter("limitThings", ['ThingsService', function(ThingsService) {
return function(entry, showOnlyFailed) {
return !showOnlyFailed || ThingsService.anyFailuresInList(entry.thing);
};
}]);
However, upon debugging, the value of "entry" turned out to be just "Object {}".