代码之家  ›  专栏  ›  技术社区  ›  Jan Nielsen

应用管道显示md输入值

  •  0
  • Jan Nielsen  · 技术社区  · 9 年前

    我在Angular 2材料应用程序中有一个表格,价格为:

      <md-input [(ngModel)]="price" placeholder="Price">
      </md-input>{{price|customCurrency}}
    

    哪一个 uses a custom version of the CurrencyPipe 如本Plnkr所示:

    http://plnkr.co/edit/OM039CYEsS5CfhEuZdBN?p=preview

    而是显示原始输入字段值:

      Price
      100              $1.00
    

    我还想申请 customCurrency 管道直接连接到输入字段显示值,因此看起来像这样:

      Price
      $1.00
    

    当我键入100时,最好是在键入时将管道应用于显示值,但前提是只能这样做 模糊 这就足够了。你知道这怎么可能吗?

    1 回复  |  直到 9 年前
        1
  •  1
  •   Jan Nielsen    9 年前

    这在角度2中是不可能的;看见 Angular 2 issue 13140 .作为一种解决方法,您可以:

      <md-input [(ngModel)]="Price" placeholder="Price: {{price|customCurrency">
      </md-input>
    

      Price: $1.00
      100
    
    推荐文章