我正在尝试同时使用AngularJS、D3、NVD3和Angular-NVD3。我在这里遵循快速指南:http: //krispo.github.io/angular-nvd3/#/quickstart和此处的饼图示例:https ://github.com/krispo/angular-nvd3/blob/gh -pages/js/pieChart.js但它对我不起作用!我在控制台中收到此错误:
错误:
Error: Invalid isolate scope definition for directive nvd3: =?
at Error (native)
at http://localhost:3000/assets/libs/angular/angular.min.js:43:202
我一直在绞尽脑汁想弄清楚我在这里做错了什么......这是我的代码:
HTML / 玉:
div(ng-app='myApp')
div(ng-controller='d3Dashboard')
nvd3(options='options', data='data')
模块:
angular.module('myApp', [
'myApp.commonController',
'myApp.filters',
'myApp.services',
'myApp.directives',
'nvd3'
]);
控制器:
angular.module('myApp.commonController', []).
controller('d3Dashboard', function ($scope) {
$scope.options = {
chart: {
type: 'pieChart',
height: 500,
x: function(d){return d.key;},
y: function(d){return d.y;},
showLabels: true,
transitionDuration: 500,
labelThreshold: 0.01,
legend: {
margin: {
top: 5,
right: 35,
bottom: 5,
left: 0
}
}
}
};
$scope.data = [
{
key: "One",
y: 5
},
{
key: "Two",
y: 2
},
{
key: "Three",
y: 9
},
{
key: "Four",
y: 7
},
{
key: "Five",
y: 4
},
{
key: "Six",
y: 3
},
{
key: "Seven",
y: .5
}
];
});
看到我做错了什么吗?
我应该只使用angularjs-nvd3-directives而不是angular-nvd3吗?
谢谢!