2015-06-29 38 views
3

我需要能夠動態顯示貨幣的值。對於一個固定的貨幣,我能夠做到:如何根據每條記錄數據動態顯示Angular.js中的貨幣?

<span id="currency-custom">{{amount | currency:'&#8377'}}</span> 

但如果我想基於改變貨幣從服務器什麼來呢?在我的控制,我有:

$scope.longestRide = { 
    'fromAddress': 'xxx', 
    'toAddress': 'yyy', 
    'mycurrency': '&#8377;', 
    'cost': '238', 
    'duration': '00:49:02' 
    } 

但這似乎並沒有工作:

<span id="currency-custom">{{amount | currency:mycurrency}}</span> 

我怎麼能顯示基於JavaScript的數據結構中的貨幣?

+0

它不應該是'{{量|貨幣:longestRide.mycurrency}}'? – Yoshi

回答

0

你應該嘗試使用內部的過濾吳冰,HTML這樣的:

<span ng-bind-html="amount | currency:mycurrency"></span> 
+0

不,實際上問題在於HTML轉義。上面的代碼的問題是,它顯示我:₹ 238.00 我需要能夠逃脫'₹' –

+0

我剛剛編輯我的答案,我認爲它應該這樣做。 – ukn

相關問題