VadimDez / ngx-order-pipe

▼ Angular 5+ orderBy pipe
https://vadimdez.github.io/ngx-order-pipe/
MIT License
243 stars 57 forks source link

Add OrderPipe as provider in the OrderModule #48

Closed VadimDez closed 6 years ago

siordache94 commented 6 years ago

Hi, I can't seem to find an example for this usage. Can you please link me one? (Sorry if this is not the appropriate place to ask) Thank you

VadimDez commented 6 years ago

@siordache94 Here: https://github.com/VadimDez/ngx-order-pipe#use-orderpipe-in-the-component

siordache94 commented 6 years ago

Yea, I find it insufficient, what is this.order? I'm getting the error: expression.indexOf is not a function

VadimDez commented 6 years ago

See Usage part, there's an example component https://github.com/VadimDez/ngx-order-pipe#usage you'll find order there

import { Component } from '@angular/core';

@Component({
  selector: 'example',
  template: `
    <ul>
      <li *ngFor="let item of array | orderBy: order">
        {{ item.name }}
      </li>
    </ul> 
  `
})

export class AppComponent {
  array: any[] = [{ name: 'John'} , { name: 'Mary' }, { name: 'Adam' }];
  order: string = 'name';
}