I'm looking through a webpage source code and it has the following div tag:
<div class="color-swatch" ng-if="quickOrderItem.colorNumber && !quickOrderItem.isCustomColor && filteredColors.length > 0" ng-repeat="color in filteredColors = (quickOrderItem.selectedSku.colorsArr | filterArrayOfObjects:quickOrderItem.colorNumber:'name':'colorNum' | limitTo:1 )">
I understand most of it, but the part that is confusing me is the very last part:
ng-repeat="color in filteredColors = (quickOrderItem.selectedSku.colorsArr | filterArrayOfObjects:quickOrderItem.colorNumber:'name':'colorNum' | limitTo:1 )"
For the sake of simplicity, I'll add some line breaks to it to make it easier to read:
ng-repeat="color in filteredColors = (
quickOrderItem.selectedSku.colorsArr |
filterArrayOfObjects:quickOrderItem.colorNumber:'name':'colorNum' |
limitTo:1 )"
What exactly is this doing? I understand that it's iterating through the filteredColors array, with each currently selected color assigned to the variable color. (Basically a for each loop)
But I have no idea what the rest of that means. Why is `color in filteredColors' equal to something else? I don't understand that. Furthermore, what exactly are those three separated things in the parenthesis doing?
Can someone help me to understand what this all means?
filteredColorsis actually resulting of the expression in parenthesis. A bit like it would in JS:for (var key in (obj = { test: 'test' })) { console.log(key );};. The|character in angular is piping input values into filters.