Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Revah authored and danrevah committed Dec 15, 2016
1 parent 571970a commit 211f00a
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -554,20 +554,12 @@ Returns object of grouped by items by discriminator

API: `array | groupBy: [string | Function]`

```javascript
import {GroupByPipe} from 'ng2-pipes/src/app/pipes/array/group-by';

@Component({
// ...
providers: [GroupByPipe]
})
export class AppComponent {
constructor(private groupByPipe: GroupByPipe) {
// ..
const arrayObject = [{elm: 'foo', value: 0}, {elm: 'bar', value: 1}, {elm: 'foo', value: 2}];
const groupedObject = groupByPipe.transform(arrayObject, 'elm'));
// `groupedObject` -> Contains: {foo: [{elm: 'foo', value: 0}, {elm: 'foo', value: 2}], bar: [{elm: 'bar', value: 1}]}
}
```typescript
this.arrayObject = [{elm: 'foo', value: 0}, {elm: 'bar', value: 1}, {elm: 'foo', value: 2}];
```

```html
<p>{{ arrayObject | groupBy: 'elm' }}</p> <!-- Output: "{foo: [{elm: 'foo', value: 0}, {elm: 'foo', value: 2}], bar: [{elm: 'bar', value: 1}]}" -->
```

## Object
Expand Down

0 comments on commit 211f00a

Please sign in to comment.