【发布时间】:2016-11-08 18:50:58
【问题描述】:
我正在尝试在 Angular2 项目(核心 v2.1.1)中使用 ng2-nvd3 (https://github.com/krispo/ng2-nvd3),但它不起作用。
我已将 nvD3 放入我的 @MgModule 的声明中:
declarations: [
...
TestComponent,
nvD3,
],
我已经按照描述设置了组件:
import {Component} from '@angular/core';
import {nvD3} from 'ng2-nvd3';
declare let d3:any;
@Component({
template: '<div><nvd3 [options]="options" [data]="data"></nvd3></div>'
})
export class TestComponent {
options;
data;
ngOnInit(){
this.options = {
chart: {
type: 'discreteBarChart',
height: 450,
margin : {
...
但我得到了错误:
EXCEPTION: Uncaught (in promise): Error: Error in ./TestComponent class TestComponent - inline template:0:31 caused by: nv is not defined
我的 package.json 文件中有 nvd3 和 d3,但我不确定应该如何处理它们。
【问题讨论】:
标签: angular d3.js nvd3.js ng2-nvd3