在Angular4中使用Angular2组件

时间:2017-07-11 09:44:56

标签: angular charts npm

有没有机会在angular4中使用angular2组件? 在我的情况下,我想使用库来生成图表: https://devarchy.com/angular/ng2-nvd3,但遗憾的是它的依赖关系对我的应用来说太低了。 Aren&#t; t angular2组件与angular4兼容?

NPM尝试安装pck

QLOOK2@0.0.0 D:\QLook2\App\trunk\QLook2.Client
+-- UNMET PEER DEPENDENCY @angular/common@4.2.4
+-- UNMET PEER DEPENDENCY @angular/core@4.2.4
+-- UNMET PEER DEPENDENCY @ngrx/store@2.2.2
`-- ng2-nvd3@2.0.0-rc3
  +-- d3@3.5.17
  +-- nvd3@1.8.5
  `-- rxjs@5.2.0

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN @ngrx/devtools@1.4.0 requires a peer of @angular/core@^2.0.0-rc.0 but none was installed.
npm WARN @ngrx/devtools@1.4.0 requires a peer of @ngrx/store@^1.5.0 but none was installed.
npm WARN angular2-google-maps@0.17.0 requires a peer of @angular/common@^2.3.1 but none was installed.
npm WARN angular2-google-maps@0.17.0 requires a peer of @angular/core@^2.3.1 but none was installed.
npm WARN ng2-select2@1.0.0-beta.10 requires a peer of @angular/core@^2.2.0 but none was installed.

PS。我无法降级应用程序'图书馆 PS2。我需要这个lib,因为我的应用程序中需要多个Y轴。

2 个答案:

答案 0 :(得分:0)

我发现的唯一解决方案(不是长期的):

转到node_modules \ webpack-dev-server \ lib并打开Server.js.

Server.prototype.checkHost = function(headers) {
    ...

    // disallow
    return false;
}

将“return false”更改为“return true”。 保存并再次运行您的项目。

答案 1 :(得分:0)

在Angular 2中构建的组件可以在Angular 4中使用,但在angular 2版本中使用的模块仅与该版本兼容。因此,您需要安装与angular 4版本兼容的模块的答案。