Sample Code (AngularJS 1.x):
var filterNameVariable = 'myFilterName'; // Given the filter name as string
In AngularJS 1.x controller, I can inject a $filter service and then inside my function I can call any filter dynamically like $filter(filterNameVariable)(...params).
In Angular 5.x components is their as similar way to call a pipe without injecting it directly at compile time. I know if we inject a pipe into the controller with its name we can call its transform method. But I don't know which pipe will be used at compile time. I will get the name of the pipe at run-time in a variable.
Sample Code (Angular 5.x):
var pipeNameVariable = 'myPipeName'; // Given the pipe name as string
How can I get the instance of appropriate pipe with above pipe name at runtime so that I can call its transform method?
One way I think of is injecting all the pipe and using switch case for above variable I can call appropriate pipe. But their are dozens of pipe and I am not interested to inject all those pipes to my component.
Any help would be greatly appreciated. Thank you in advance.