Angular2 - assign pipe from a variable

前端 未结 1 800
半阙折子戏
半阙折子戏 2020-12-20 02:09

Is it possible something like this:

{{property | some_variable_name}}

My goal is to use a pipe that is set in a JSON

相关标签:
1条回答
  • 2020-12-20 02:27

    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.

    0 讨论(0)
提交回复
热议问题