我正在尝试使用AngularJS、D3、NVD3和AngularJS 3。我遵循这里的快速指南: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 / Jade:
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 3指令而不是角-nvd3 3吗?
谢谢!
发布于 2015-05-16 15:45:48
使用=?语法,角-nvd3 3库似乎将其一些作用域属性设置为可选属性。这是添加在角1.1.4 (提交#ac899d0),似乎是一个打破(非向后兼容)的变化.
因此,为了使用新版本的角-nvd3 3,您将需要一个新版本的角。
https://stackoverflow.com/questions/30270198
复制相似问题