Using pipe name as a variable in the template in Angular2

心已入冬 提交于 2019-12-07 10:13:30

问题


I am struggling with using a standard angular2 pipe in a non-standard way and I was wondering if there are any ways around it.

Assume I have a variable which its value equals the definition of a standard pipe, for example, the common "date:'medium'" pipe.

let a = "date:\':medium\'";

Now, somewhere in my html, I would like to be able to use this "a" variable the following way:

<p>{{myRecord.date | a}}</p>

And I want this "a" to have the same effect of the date pipe it contains. Is there any way to achieve this?

来源:https://stackoverflow.com/questions/43788650/using-pipe-name-as-a-variable-in-the-template-in-angular2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!