You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think it is better to keep return types consistent to avoid unexpected behavior, such as use of a filter inside ng-repeat, which causes ng-repeat to iterate over object properties instead of the object itself.
Replace "return (count < 2) ? result[0] : result;" with just "return result;" inside "getFirstMatches" function.
The text was updated successfully, but these errors were encountered:
We could do something like that:
If filter get an arguments (e.g: collection | first: 1: expression ), it's return result as array.
But, if it doesn't (e.g: collection | first ), it's return an object(the first one).
so, we could do something like that:
<h1> {{ collection | first }}</h1><!-- or --><thng-repeat="col in collection | first: 1: 'expression'">
{{ col }}
</th>
I like this, and then collection | first | expression would also return an object? In my case n=3, but sometimes collection would have only one item, resulting in unexpected behavior.
@ostruk only filter without an arguments return an object
e.g: collection | first object collection | first: n array collection | first: expression array collection | first: n: expression array
I think it is better to keep return types consistent to avoid unexpected behavior, such as use of a filter inside ng-repeat, which causes ng-repeat to iterate over object properties instead of the object itself.
Replace "return (count < 2) ? result[0] : result;" with just "return result;" inside "getFirstMatches" function.
The text was updated successfully, but these errors were encountered: