首页 文章

使用“angular 2-google-chart”时出错

提问于
浏览
1

我想使用这个模块“angular2-google-chart” .

但是在启动应用程序时,会收到以下错误:

./node_modules/angular2-google-chart/directives/angular2-google-chart.directive.ts中的错误 . 模块构建失败:错误:/ home / user / Desk / project / frontend / node_modules / angular2-google-chart / directives TypeScript编译中缺少/angular2-google-chart.directive.ts . 请通过'files'或'include'属性确保它在您的tsconfig中 . 丢失的文件似乎是第三方库的一部分 . 已发布库中的TS文件通常是包装严重的库的标志 . 请在库存储库中打开一个问题,提醒其作者并要求他们使用Angular Package Format(/goo.gl/jB3GVv)打包库 . 在plugin.done.then的AngularCompilerPlugin.getCompiledFile(/home/user/Desk/project/frontend/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:674:23)(/ home / user / Desk / project / frontend) /node_modules/@ngtools/webpack/src/loader.js:467:39)at process._tickCallback(internal / process / next_tick.js:182:7)

如何解决这个错误?

1 回答

  • 0

    那个错误路径问题 . 您必须复制 angular2-google-chart.directive.ts 文件并粘贴一些项目文件夹,如资产或任何东西,然后导入使用它解决问题 .

    这是一个工作的示例演示,你给我提到了你提到的“angular2-google-chart

    https://stackblitz.com/edit/angular-zp46ve

    安装:-

    npm install angular2-google-chart
    

    的index.html

    <head>
        <script src="https://www.gstatic.com/charts/loader.js"></script>
        <script>  
            // !important: You want to give this variable(var googleLoaded = false;). This is used to run multiple chart in your jade.
            var googleLoaded = false;
            // !important: Define which chart packages to preload.Because this package uses ChartWrappers you can use any chart type that Google supports, but if it // isn't loaded it will load it on demand. 
            var googleChartsPackagesToLoad = ['geochart'];
        </script>
        </head>
    

    app.module.ts

    import {GoogleChart} from './angular2-google-chart.directive';
    
    @NgModule({
      declarations: [
        GoogleChart
      ],...
    

    输出截图,

    enter image description here

    我希望它能帮助你开始 . 如果有任何错误让我知道 .

相关问题