How can I implement dynamic pipe invocation in Angular 2 using reflection or a similar method? I have a string containing the name of the desired pipe (e.g. "lowercase") and I want to apply that pipe to a value using only the string.
For instance:
JSON
var cols = [{ dataProperty: "city", pipeName: "lowercase"},{ dataProperty: "state", pipeName: "uppercase"}]
var rows = [{city: 'Walla Walla', state: 'wa'}];
HTML (Angular component excerpt)
{{ rowData[col.dataProperty] | this.[col.pipeName] }}
However, this implementation did not yield the expected results.
Is there an alternative to using this.[col.pipeName]
to dynamically invoke the appropriate pipe based on the provided pipe name, such as calling uppercase
or lowercase
, assuming the specified pipe is accessible in my code?