cytoscape.js angular2 打字稿使用
cytoscape.js angular2 typescript use
有一个用 Webpack 打包的 angular4 应用程序。
想使用 cytoscape.js。为此需要使用 npm 模块:https://www.npmjs.com/package/ng2-cytoscape
我已经按照该页面进行了更改,只是有所不同
import {NgCytoscapeModule} from "ng2-cytoscape";
而不是"ng2-cytoscape/dist"; (给出编译错误)
然后将以下行添加到 app.module.ts
import {NgCytoscapeModule} from 'ng2-cytoscape';
@NgModule({
imports: [
NgCytoscapeModule
],
此外,将依赖项添加到 package.json
"dependencies": {
"ng2-cytoscape": "^0.2.0",
}
这会产生以下错误:
compiler.es5.js:1540 Uncaught Error: Unexpected value 'NgCytoscapeModule' imported by the module 'AppModule'. Please add a @NgModule annotation.
at syntaxError (compiler.es5.js:1540)
这是什么原因?在 Angular 2 - Typescript 中还有其他使用 cytoscape.js 的方法吗?
Cytoscape 没有 Angular 的官方支持包。如果您想使用 Cytoscape,请使用官方 cytoscape
包并编写您自己的 Angular 适合您需要的集成。
有一个用 Webpack 打包的 angular4 应用程序。
想使用 cytoscape.js。为此需要使用 npm 模块:https://www.npmjs.com/package/ng2-cytoscape
我已经按照该页面进行了更改,只是有所不同
import {NgCytoscapeModule} from "ng2-cytoscape";
而不是"ng2-cytoscape/dist"; (给出编译错误)
然后将以下行添加到 app.module.ts
import {NgCytoscapeModule} from 'ng2-cytoscape';
@NgModule({
imports: [
NgCytoscapeModule
],
此外,将依赖项添加到 package.json
"dependencies": {
"ng2-cytoscape": "^0.2.0",
}
这会产生以下错误:
compiler.es5.js:1540 Uncaught Error: Unexpected value 'NgCytoscapeModule' imported by the module 'AppModule'. Please add a @NgModule annotation.
at syntaxError (compiler.es5.js:1540)
这是什么原因?在 Angular 2 - Typescript 中还有其他使用 cytoscape.js 的方法吗?
Cytoscape 没有 Angular 的官方支持包。如果您想使用 Cytoscape,请使用官方 cytoscape
包并编写您自己的 Angular 适合您需要的集成。