Hello,
I thought the Pipe would be injectable in the constructor of my component so I can call translatePipe.transform(mytext)...
What is the way to do this ?
thank you
Hello,
yes you can do that, see the tests: https://github.com/ocombe/ng2-translate/blob/master/tests/translate.pipe.spec.ts#L87
But then at the point you might as well use the service which does the same with a lot less of overhead :)
Hello and thank you,
the problem not in test, is that the pipe is not available as a provider, so I can't inject it.
How am I supposed to get the pipe ?
thank you
I guess that you have to provide it either in your module or in your component (using the providers property), but like I said you really should be using the service instead.
ok I follow your advice,
thank you
@ocombe
Using as pipe is shorter than making sub. Very useful when creating dynamics forms.
this.translatePipe.transform('countryOfOriginCode'),
Please add this metod to docs :+1: or please show me better way.
You can use "instant": this.translateService.instant('countryOfOriginCode'). Be careful, like the pipe transform, this is synchronous so you have to make sure that the translations have been loaded, otherwise it will return the key instead of the translation
Most helpful comment
You can use "instant":
this.translateService.instant('countryOfOriginCode'). Be careful, like the pipe transform, this is synchronous so you have to make sure that the translations have been loaded, otherwise it will return the key instead of the translation