-
Notifications
You must be signed in to change notification settings - Fork 329
Closed
Labels
Description
defaultsFilter allows to specify a default fallback value for properties that resolve to undefined.
Example:
$scope.orders = [
{ id:1, destination: { zip: 21908 }, name: 'Ariel M' },
{ id:2, name: 'John F' },
{ id:3, destination: { zip: 45841 } },
{ id:4, destination: { zip: 78612 }, name: 'Danno L' },
];
$scope.defaultValue = {
name: 'Customer name not available',
destination: { zip: 'Pickup' }
};<li ng-repeat="order in orders | defaults: defaultValue">
<b>id:</b> {{ order.id }},
<b>name:</b> {{ order.name }},
<b>shipping address:</b> {{ order.destination.zip }}
</li>Results:
- id: 1, name: Ariel M, shipping address: 21908
- id: 2, name: John F, shipping address: Pickup
- id: 3, name: Customer name not available, shipping address: 45841
- id: 4, name: Danno L, shipping address: 78612