Angular2 - assign pipe from a variable

Radoslav Stoyanov

Is it possible something like this:

{{property | some_variable_name}}

My goal is to use a pipe that is set in a JSON configuration (or a variable), but I'm not sure if it is possible to pass the pipe name in the interpolation this way.
Anybody tried something like this before?

Günter Zöchbauer

The pipe needs to be listed in pipes: [MyPipeHere] in the @Component() decorator or in PLATFORM_PIPES, therefore this approach won't work.

What you can do instead is creating a custom pipe that calls other "pipes". A pipe is basically just a function, therefore this is easy.

You can pass a variable to your custom pipe like

{{property | my_custom_pipe:some_variable_name}}

this should be pretty close to what you want.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Assign jade variable to Angular

From Dev

Is there a way to pipe from a variable?

From Dev

Powershell - Extract Variable from Pipe

From Dev

Angular2 detect variable change in parent from centralized data

From Dev

Assign the output of a pipe in angular2 to a variable

From Dev

Access a local variable from the template in the controller in Angular2

From Dev

Angular2: call method or variable from other component

From Dev

Angular 2 pipe/filter with component variable

From Dev

Angular2 - assign pipe from a variable

From Dev

How to consume single Observable property in view from Angular2 component using async pipe?

From Dev

Form to assign value from variable

From Dev

Assign variable from text

From Dev

How to Assign Variable from Thread

From Dev

Is there a way to pipe from a variable?

From Dev

Assign element from array to variable?

From Dev

How to assign a variable within a pipe

From Dev

Expand Environment Variable from PIPE (SHELL)

From Dev

Powershell - Extract Variable from Pipe

From Dev

dash: read variable from pipe

From Dev

Angular 2 pipe/filter with component variable

From Dev

Get data from angular 2 pipe

From Dev

Is it possible to set variable javascript variables outside from angular2?

From Dev

Assign a value to an internal variable in a function angular2

From Dev

angular2 - pipe error

From Dev

Access variable from parent in child angular2

From Dev

Angular 2 Pipe From Filtered JSON

From Dev

Assign variable gotten from JSON

From Dev

Pass a variable by reference from Angular2 template

From Dev

how to value is assign to reference variable in angular 2?