0
我是AngularJS的新手。我需要連接角劇本情節。這個想法是爲Plotly獲取X和Y的JSON數據。一切都很好,直到積極線。它找不到我的div chart0,chart1,chart2等等。但它們是由ng-repeat($ index)生成的。我得到錯誤「頁面上不存在帶有id'chart2'的DOM元素」。這是我的代碼:AngularJS + Plotly - 不想找到我的#div
app.controller('archive', function($scope, $http) {
var layout = { margin: { l: 40, r: 20, b: 35, t: 20, pad: 4 } }
$http.get("json.php?module=archive").then(function(response) {
$scope.sensors = response.data;
angular.forEach($scope.sensors, function(value, key) {
var data = [{ x: value.x.split(","), y: value.y.split(","), type: 'scatter', name: value.name }];
Plotly.newPlot("chart"+(key-1), data, layout, {displaylogo: false, showLink: false, autosize: false});
});
}, function(response) {
alert("Error: "+response);
});
});