2

I wanted to use this feature to create global pipe: https://angular.io/docs/ts/latest/api/core/index/PLATFORM_PIPES-let.html

But this is deprecated, and it says: Providing platform pipes via a provider is deprecated. Provide platform pipes via an AppModule instead.

Documentation is really non-existent, here is the old version I need to make into newer one:

import {PLATFORM_PIPES} from '@angular/core';
import {OtherPipe} from './myPipe';
@Component({
  selector: 'my-component',
  template: `
    {{123 | other-pipe}}
  `
})
export class MyComponent {
  ...
}
bootstrap(MyComponent, [{provide: PLATFORM_PIPES, useValue: [OtherPipe], multi:true}]);

So does anyone know how to transform this example to new version that uses AppModule?

Teddy
  • 2,277
  • 3
  • 15
  • 19

1 Answers1

3

AppModules are quite new and were changed quite a bit recently (will probably land in RC.5). I'd stick with the deprecated method for now.

I haven't tested it but something like this should do what you want:

@AppModule({
  // modules: [MyModule],
  providers: [...]
  pipes: [OtherPipe]
})
class MyModule {}

bootstrap(AppCmp, {modules: [RouterModule, MyModule])
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567