导出的consts未定义(Angular,TypeScript)

时间:2017-12-13 16:48:49

标签: angular typescript cesium

我有一个文件声明了一些常量,如:

// color-constants.ts: no imports in this file
export const aoiToImageMaterial = new Cesium.ColorMaterialProperty(
    new Cesium.Color(0.4, 0.6, 0.8, 0.1)
);

export const aoiToImageOutline = new Cesium.Color(0.4, 0.6, 0.8, 1);

但是,当我将它们导入我的Angular组件文件时,它们会返回undefined

import { Component, Input } from '@angular/core';

import { Aoi } from '../../../models/aoi.model';
import * as colorConstants from '../../color-constants';

@Component({
  selector: 'cs-aoi',
  templateUrl: './aoi.component.html',
  styleUrls: ['./aoi.component.scss']
})
export class AoiComponent {
  @Input('aoi') aoi: Aoi;

  materialProperty;
  outlineColor;

  constructor() {
    this.materialProperty = colorConstants.aoiToImageMaterial; // undefined
    this.outlineColor = colorConstants.aoiToImageOutline; // undefined
  }

}

如果我在组件文件中声明这些常量,它会按预期工作,因此问题是导入/导出。 color-constants.ts文件没有导入任何内容,所以我怀疑这是一个循环依赖问题。有人可以帮忙吗?

0 个答案:

没有答案