0

How to implemenet sorting data in table with angular 2? With pipe? For example table 5 x 5, click on first cell (on button maybe), and sort all column.

1

1 Answer 1

2

The Angular team has advised that you don't use filter pipes in Angular2, as it is an extremely expensive operation.

"The Angular team and many experienced Angular developers strongly recommend that you move filtering and sorting logic into the component itself. The component can expose a filteredHeroes or sortedHeroes property and take control over when and how often to execute the supporting logic. Any capabilities that you would have put in a pipe and shared across the app can be written in a filtering/sorting service and injected into the component."

Now that Angular apps are component based, it is even easier to take this approach when trying to implement any client-side logic that could crush your app's overall performance.

Check out https://angular.io/docs/ts/latest/guide/pipes.html#!#no-filter-pipe for more info.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.