2017-06-09 10 views
1

こんにちは私はAngular2を使用して入力ボックスに通貨​​を表示しようとしています。今、私はAngular2はngModelで通貨を使用しています

<p class="list-group-item-text">${{ item.price | number : '1.2-2'}}</p> 
<input type="text" class="form-control" [(ngModel)]="item.price"> 

を持っており、アウトプットは

enter image description here

であると私は探していますがボックス内のテキストは、ボックスの上にテキストと同じになることです。

+0

これは角度よりもむしろcssの問題です。この問題を確認する:https://stackoverflow.com/questions/2913236/html-text-input-field-with-currency-symbol – AArias

+0

この問題を確認してくださいhttps://stackoverflow.com/questions/40346676/angular-2-using -pipes-with-ngmodel – alehn96

答えて

1

このパッケージを試してみてください:https://www.npmjs.com/package/ng2-currency-mask

これを追加すると、それはあなたの入力にcurrencyMaskを追加するのと同じくらい簡単です。

<input currencyMask [(ngModel)]="value" /> 
関連する問題