AngularJS - OrderBy Filter
groupFields = $filter('orderBy')(groupFields, ['locationX', 'locationY']);
参考资料
Angular - Pipe
- Angular doesn’t come with an orderBy filter out of the box, but if we decide we need one we can easily make one.
import { Pipe, PipeTransform } from "@angular/core";
import { orderBy, sortBy } from "lodash-es";
- lodash
- lodash.com/docs/4.17.15
- Recently I realised that lodash package is just not tree shakable, so if you need tree shaking just use lodash-es instead.
npm install lodash-es --save npm install @types/lodash-es --save-dev
Use it as:import debounce from 'lodash-es/debounce'
debounce()
参考资料
- OrderBy pipe issue
- Sort/OrderBy pipe in Angular 5/6/7/8/9 — Part II
- Angular 6 by Example by Chandermani Arora, Kevin Hennessy
- TIL: Importing Lodash into Angular, the better way.
- Correct way of importing and using lodash in Angular