Angular 2. How to apply orderBy?

后端 未结 4 2015
没有蜡笔的小新
没有蜡笔的小新 2020-12-03 04:13

I have a piece of code.



        
4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-03 04:34

    If you are using lodash your pipe can be like this:

    import { Pipe, PipeTransform } from '@angular/core';
    import { orderBy } from 'lodash';
    
    @Pipe({
      name: 'orderBy'
    })
    export class OrderByPipe implements PipeTransform {
      transform = orderBy;
    }
    

    And then you can use all the power of the method:

  • {{product.name}}
提交回复
热议问题