VadimDez / ngx-order-pipe

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

Help for a newbie #56

Closed b0rgbart3 closed 6 years ago

b0rgbart3 commented 6 years ago

Hi guys - I'm trying to use the OrderBy Pipe - but I can't seem to get it installed. If I clone the whole Git Repo - I can launch the demo app on my local system - no problem.

But when I try to include the Pipe in my own Angular App - I can't seem to get it installed correctly.

Here's what I've done: I installed the ngx-order-pipe using npm ( and it's listed in my package.json file under: 'dependencies' : "ngx-order-pipe": "^2.0.1", )

I included the OrderModule in my AppModule - under imports

And the component in question has this import: import { OrderPipe } from 'ngx-order-pipe';

My template has this line: <div *ngFor="let user of sortedUsers | orderBy: order">

The error I'm getting (from the console) is: compiler.js:466 Uncaught Error: Template parse errors: The pipe 'orderBy' could not be found ("

-- I also tried including the OrderPipe as a Provider in the AppModule - but that didn't help either. Help!

Any advice on what I'm missing or what else I should try would be greatly appreciated. Thanks!

VadimDez commented 6 years ago

You have to import OrderModule to your module.

import { NgModule } from '@angular/core';
import { BrowserModule  } from '@angular/platform-browser';
import { AppComponent } from './app';

import { OrderModule } from 'ngx-order-pipe';

@NgModule({
  imports: [BrowserModule, OrderModule],
  declarations: [AppComponent],
  bootstrap: [AppComponent]
})
export class AppModule {}

See https://github.com/VadimDez/ngx-order-pipe#usage