Error: No provider for TranslatePipe!
See original GitHub issueI’m submitting a … (check one with “x”)
[x] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request
Current behavior
When trying to inject TranslatePipe (in another Pipe, as an helper), I get the error “Error: No provider for TranslatePipe!”
Expected/desired behavior
We should be able to either inject the Pipe, or have a service/proper Injectable doing the similar heavy lifting to allow easier integration with custom pipes
Reproduction of the problem http://plnkr.co/edit/Yjh9qLSzLSfCWI77xW3f?p=info
What is the motivation / use case for changing the behavior?
Chaining pipes is nice, but troublesome. being able to have a single pipe taking care of everything would be much better. If we can’t, we will ALWAYS end up doing 'my-value' | customPipe | translate
. It’s a pain.
Please tell us about your environment:
- ngx-translate version: 7.0.0
- Angular version: 4.1.3
- Browser: all
PS: I consider this a bug as it’s been advised previously to inject the pipe in a service or another pipe. Plus the pipe is tagged as @Injectable
, so I expect to be able to inject it.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:9
- Comments:20
Top GitHub Comments
One more way
Why not use the translate service
instant
method instead which is synchronous and doesn’t use an observable?And I replied to your questions, you can’t declare it at app level because the pipe uses
ChangeDetectorRef
which is for components and directives. What kind of design is this? The one from the Angular team.