我有这个玉模板:
html
head
script(type="text/javascript" src="https://www.google.com/jsapi")
script(type='text/javascript')
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Date', 'Tin_A' ],
- each datapoint in myData
"[" + datapoint.date + "," + datapoint.value + "],"
]);
var options = {
title: 'bla'
};
var chart = new google.visualization.LineChart(document.getElementById('chart_line'));
chart.draw(data, options);
}
body
h1= title
#chart_line
我正在使用此调用在 express/node.js 中呈现翡翠模板:
app.get('/', function(req, res){
sensors.findSensorAllData(2, 2, function (error,emps){
console.log(emps);
res.render('tmp', {
title : 'Temperatures in a row',
myData : emps
});
});
});
的输出console.log(emps)
是:
[ { _id: 524b8642028e167fb0e3661d,
sensor_id: 2,
value: 49,
date: Tue Oct 01 2013 20:34:40 GMT-0600 (CST) },
{ _id: 524b863d028e167fb0e3661c,
sensor_id: 2,
value: 19,
date: Tue Oct 01 2013 20:34:35 GMT-0600 (CST) } ]
在渲染发生后,我希望在玉模板的 javascrip 中有值......但它不起作用。我在纯文本中只得到相同的行,好像该行- each datapoing in myData
没有意义......我做错了什么?谢谢
--- 编辑:如果我更换线路,一切正常
- each datapoint in myData
"[" + datapoint.date + "," + datapoint.value + "],"
和
['2004', 20],
['2005', 30],
['2006', 40]