Angular 2 Pipe under condition

前端 未结 4 1975
醉梦人生
醉梦人生 2020-12-03 00:38

Is it possible in Angular 2 to apply a pipe under condition? I would like to do something like:

{{ variable.text | (variable.value ? SomePipe : OtherPipe) }         


        
4条回答
  •  执笔经年
    2020-12-03 00:50

    You need to change the syntax a bit:

    {{variable.value ? (variable.text | SomePipe) : (variable.text | pipe2)}}
    

    Plunker example

提交回复
热议问题