下面我有一個Angular表達式{{USA_Visits.maximum.value |number:0 }}
,我希望在JavaScript中使用它來生成圖表。這是我當前的代碼:將角度表達式傳遞到Javascript
<!-- Angular expression -->
{{USA_Visits.maximum.value |number:0 }}
<!-- Chart code -->
<script>
var chart = AmCharts.makeChart("chartdiv", {
"theme": "light",
"type": "serial",
"startDuration": 2,
"dataProvider": [{
"country": "USA",
"visits": {{USA_Visits.maximum.value |number:0 }},
"color": "#FF0F00"
}, {
"country": "Taiwan",
"visits": 500,
"color": "#333333"
}],
"valueAxes": [{
"position": "left",
"axisAlpha":0,
"gridAlpha":0
}],
"graphs": [{
"balloonText": "[[category]]: <b>[[value]]</b>",
"colorField": "color",
"fillAlphas": 0.85,
"lineAlpha": 0.1,
"type": "column",
"topRadius":1,
"valueField": "visits"
}],
"depth3D": 40,
"angle": 30,
"chartCursor": {
"categoryBalloonEnabled": false,
"cursorAlpha": 0,
"zoomable": false
},
"categoryField": "country",
"categoryAxis": {
"gridPosition": "start",
"axisAlpha":0,
"gridAlpha":0
},
"export": {
"enabled": true
}
}, 0);
</script>
<!-- HTML -->
<div id="chartdiv"></div>
JS代碼內顯然分配"visits": {{USA_Visits.maximum.value |number:0 }}
不工作。我怎樣才能做到這一點?
謝謝
你能發佈你得到的錯誤嗎?這將有助於確定爲什麼該財產沒有得到你想要的價值。 – henrisycip
[如何在控制器中使用過濾器?](https://stackoverflow.com/questions/14302267/how-to-use-a-filter-in-a-controller) – Icycool
可能的重複我不認爲這是一個重複的@Icycool ... 這是我試圖做的JSfiddle。在這種情況下,我想將{{quantity * cost}}傳遞給Javascript。 https://jsfiddle.net/7hj7huj3/ –