xieziyu / ngx-echarts

An angular (ver >= 2.x) directive for ECharts (ver >= 3.x)
https://xieziyu.github.io/ngx-echarts/
MIT License
1.11k stars 197 forks source link

angular 5.0.0 ng-alain使用ngx-echarts报错Can't bind to 'options' since it isn't a known property of 'div' #140

Open canacan opened 6 years ago

canacan commented 6 years ago

uncaught Error: Template parse errors: Can't bind to 'options' since it isn't a known property of 'div'. (" 条形图 <div echarts [ERROR ->][options]="chartOption" [ngStyle]="{height: '400px'}">

  1. npm install echarts --save
  2. npm install ngx-echarts@2.3.1 --save
  3. 在angular.json中加入 "scripts": [ "node_modules/echarts/dist/echarts.min.js" ]
  4. AppModule中import NgxEchartsModule
  5. html <div echarts [options]="chartOption" [ngStyle]="{height: '400px'}"></div
  6. component.js chartOption = {...}//拷贝自https://github.com/xieziyu/ngx-echarts/blob/v2.x/README.md

另外, 之前试过viser,也报类似的错误

xieziyu commented 6 years ago

@canacan 在你真正需要使用echarts指令的module中import NgxEchartsModule

kvloover commented 6 years ago

Had the same issue, even with proper imports. The issue appeared to be a mismatch with the online demo installation guide and the installation steps on the github page.

you do NOT need to add the following to you angular.json : "../node_modules/echarts/dist/echarts.min.js"