下面我有一个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/ –