gpt4 book ai didi

typescript - ERROR in Error during template compile of 'AppModule' 装饰器不支持函数调用,但调用了 'ChartModule'

转载 作者:搜寻专家 更新时间:2023-10-30 20:53:08 24 4
gpt4 key购买 nike

我在我的 Angular 项目上安装了 angular2-highcharts,并实现了它。它在 ng serve 模式下工作。但是当我执行命令时 ng build --prod。我收到错误:

AppModule 模板编译时出错

装饰器不支持函数调用,但调用了 ChartModule

当我执行 ng build 时它工作正常。

这是我的app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { NgModule } from '@angular/core';
import { ChartModule } from 'angular2-highcharts';
import { AppComponent } from './app.component';
import { HttpModule } from '@angular/http';

declare var require : any;

@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,HttpModule,
ChartModule.forRoot(require('highcharts/highstock'),require('highcharts/modules/drilldown')),
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
platformBrowserDynamic().bootstrapModule(AppModule);

最佳答案

基本上您不能在 forRoot 函数内部进行任何函数调用。

这里讨论了类似的问题:https://github.com/angular/angular-cli/issues/9358

关于typescript - ERROR in Error during template compile of 'AppModule' 装饰器不支持函数调用,但调用了 'ChartModule',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48618331/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com