-1

So I was following this post access key and value of object using *ngFor

However I'm getting a 'pipe could not be found error'.

  • I've done this @Pipe({name: 'keys'})

  • I've exported the class.

  • I've imported it in my app.module.ts

  • I've put it in the declarations

  • I've included it in my app.component.ts (where I'm using it)

What else am I missing?

Community
  • 1
  • 1
A. L
  • 10,555
  • 20
  • 75
  • 142

2 Answers2

2

Create pipe using below command: ng g p double

if you are using angular2 cli then only you need to add filter like `{{ mytext | double }} in your template html.

There is no need to add file in your component but check the pipe should be included in app.module.ts @NgModule({declarations: [DoublePipe]}) .

him
  • 2,925
  • 3
  • 12
  • 17
0

Have you put it in your AppModule's providers list?

Harry Ninh
  • 15,280
  • 5
  • 59
  • 54
  • It works now for some reason... should it be in `declarations` or `providers`? Because it's in declarations right now and it works. Maybe I just didn't let it update... there seems to be a caching issue with Angular 2, where it won't display updates unless you delete the cache. – A. L Dec 11 '16 at 22:57