angular-cli:无法导出指令MyComponent,因为它既未声明也未导入

时间:2020-03-08 12:34:18

标签: angular angular-cli

我跑步时

npm run build --prod

我得到了错误

ERROR in : Can't export directive CandlestickAndVolumeComponent in 
C:/ClientApp/src/app/components/charts/candlestick-and-volume/candlestick-and-volume.component.ts 
from BackdataJobDetailDashboardModule in 
C:/ClientApp/src/app/dashboards/BackData/backdata-job-detail-dashboard/backdata-job-detail-dashboard.module.ts 
as it was neither declared nor imported!

我跑步时

npm start

一切正常

尽管错误消息很清楚,但是我对angular-cli不太熟悉,所以我无法解决该问题的解决方法

这是我的backdata-job-detail-dashboard.module.ts

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { CandlestickAndVolumeComponent } from '@app/components/charts/candlestick-and-volume/candlestick-and-volume.component';
import { ChartModule, HIGHCHARTS_MODULES } from 'angular-highcharts';
import stock from 'highcharts/modules/stock.src';
import more from 'highcharts/highcharts-more.src';
import { BackdataJobDetailDashboardRoutingModule } from './backdata-job-detail-dashboard-routing.module';

export function highchartsModules() {
  // apply Highcharts Modules to this array
  return [stock, more];
}

@NgModule({
  declarations: [],
  imports: [CommonModule, BackdataJobDetailDashboardRoutingModule, ChartModule],
  exports: [CandlestickAndVolumeComponent],
  providers: [
    { provide: HIGHCHARTS_MODULES, useFactory: highchartsModules } // add as factory to your providers
  ]
})
export class BackdataJobDetailDashboardModule {}

这是我的烛台和volume.component.ts

import { Component, OnInit } from '@angular/core';
import { StockChart } from 'angular-highcharts';
import { ApiService } from '@app/services/snakeApi/api.service';
import { ActivatedRoute } from '@angular/router';
import { finalize } from 'rxjs/operators';
import { ChartDataCandleStick, ChartDataIndicator } from '@app/model/ChartData';
import { Options } from 'highcharts/highstock';
import { WorkFlow } from '@app/model/WorkFlows/WorkFlow';
import { TradingDataService } from '@app/services/Data/trading-data.service';

@Component({
  selector: 'app-candlestick-and-volume',
  templateUrl: './candlestick-and-volume.component.html',
  styleUrls: ['./candlestick-and-volume.component.scss']
})
export class CandlestickAndVolumeComponent implements OnInit {
...
}

有什么想法吗?

0 个答案:

没有答案