【发布时间】:2016-04-16 17:04:53
【问题描述】:
我尝试将 angular-cli 与 D3 一起使用。 之后
typings install d3 --save
npm install d3
我在 node_modules 中有
在typings文件夹中
angular-cli-build.js
module.exports = function(defaults) {
var app = new Angular2App(defaults, {
vendorNpmFiles: ['d3/d3.js']
});
return app.toTree();
};
index.html
System.config({
packages: {
app: {
format: 'register',
defaultExtension: 'js'
}
},
d3: {
'd3': 'vendor/d3/d3.js'
}
});
在bar-chart 指令中我尝试导入 d3
import {Directive} from 'angular2/core';
import d3 from 'd3';
@Directive({
selector: 'bar-graph',
providers: [],
host: {},
})
export class BarGraph {
constructor() {
console.log(d3);
}
}
但应用程序永远不会加载,console.log 说它试图获取 localhost:4200/d3。
【问题讨论】:
-
你找到答案了吗
标签: javascript angularjs d3.js angular-cli