我有一个看起来像这样的控制器
function ChartController($scope, $location, Chart) {
$scope.$on('$locationChangeSuccess', function(event) {
var c = Chart.get({chart_name: $location.hash()}, function(data) {
$scope.chart = data;
});
});
}
这按预期显示了json。我检查typeof data
按预期返回一个对象但是当我尝试创建一个div并将其放在页面上时,它给了我一个错误。
function ChartController($scope, $location, Chart) {
$scope.$on('$locationChangeSuccess', function(event) {
var c = Chart.get({chart_name: $location.hash()}, function(data) {
var chart = $('<div/>').highcharts(data);
$scope.chart = chart;
});
});
}
这给了我以下错误:
TypeError: Converting circular structure to JSON
at Object.stringify (native)
at toJson (http://127.0.0.1:5000/pmstats/static/lib/angular/angular.js:762:15)
at Object.$get.fn (http://127.0.0.1:5000/pmstats/static/lib/angular/angular.js:4981:24)
at Object.$get.Scope.$digest (http://127.0.0.1:5000/pmstats/static/lib/angular/angular.js:7935:38)
at Object.$get.Scope.$apply (http://127.0.0.1:5000/pmstats/static/lib/angular/angular.js:8143:24)
at done (http://127.0.0.1:5000/pmstats/static/lib/angular/angular.js:9170:20)
at completeRequest (http://127.0.0.1:5000/pmstats/static/lib/angular/angular.js:9333:7)
at XMLHttpRequest.xhr.onreadystatechange (http://127.0.0.1:5000/pmstats/static/lib/angular/angular.js:9303:11) angular.js:5754
(anonymous function) angular.js:5754
$get angular.js:4846
$get.Scope.$digest angular.js:7954
$get.Scope.$apply angular.js:8143
done angular.js:9170
completeRequest angular.js:9333
xhr.onreadystatechange
为什么会触发此错误?