【问题标题】:Angular 5: Error during template compile of 'AppModule'Angular 5:“AppModule”模板编译期间出错
【发布时间】:2018-03-20 02:23:47
【问题描述】:

注意: 我没有意识到针对此问题发布了错误的代码和错误,我已将此问题移至另一个帖子Angular 5: Function calls are not supported in decorators

对于那些花时间回答的人,我感到非常抱歉。非常感谢您的回复。

【问题讨论】:

  • 您使用的是哪个版本的 Angular CLI?这可能与github.com/angular/angular/issues/21273 错误有关
  • 你能用 1.7.3 试试吗?另外,是否可以提供此错误的最低工作示例?
  • 基类BaseEnvironment导出了吗?
  • 1. BaseEnviroment 是否已导入此文件? & 你能改变导出变量名,例如“export const environment”到“export const environment_something”。因为这个导出已经存在!
  • 我将关闭它并创建一个新帖子,因为我一开始就有错误的代码和错误。很抱歉,感谢您的帮助。

标签: angular typescript progressive-web-apps


【解决方案1】:

我想这就是你想要的

import { ProspectBuilderModel } from '../app/models/prospect';
//IMPORT BaseEnvironment CLASS!!!!

export class Environment extends BaseEnvironment {
  production: boolean;
  prospectBuilderModel: ProspectBuilderModel = new ProspectBuilderModel();
}

export const environment: Environment = {
    production: true,
    prospectBuilderModel:{
        buildQuote: true,
        buildAcknowledge: true,
        buildOrganizationInfo: true,
        buildFinancialInfo: true,
        buildTradeInfo: true,
        buildPermissiblePurpose: true,
        buildUserSetup: true,
        buildPackageSelection: true,
        buildPaymentOptions: true,
        buildOrderOptions: true,
        buildVerifyOrganizationInfo: true,
        buildDocusignAuthorization: true,
        buildDocusignContract: true,
        //whatever other properties the BaseEnvironment Class has
    }
}

BaseEnvironment 类可能是错误所说的未导出,因为您没有导入它,也没有在 Environment 类上方或下方定义它。如果它被定义了,你会有

export class BaseEnvironment {...}

关键字是EXPORT。

const 也是只读的,这样做

export const environment: Environment = new Environment();

只需将其设置为空 Environment,这意味着您不能做类似的事情

this.environment.production = false;

如果您想要切换某些内容而无法正常工作,因为您假设在 const 中定义值或将其属性设置为目标将包含您想要的数据/设置的其他变量 const去收集。如果你做一个 plunkr 或 stackblitz 以便我们可以看到你在那里做了什么,如果这不能解决它,我可能会提供更多帮助。

【讨论】:

  • 我没有意识到(直到我阅读了我正在查看错误文件的 cmets,因为我试图在 prod 中运行。我现在添加了正确的文件代码和更新的错误消息得到。
  • 感谢您的回复和可能的解决方案。你能用正确文件中的代码和新的错误代码再看一遍帖子,让我知道你的想法吗?
  • 我将关闭它并创建一个新帖子,因为我一开始就有错误的代码和错误。很抱歉,感谢您的帮助
猜你喜欢
  • 2018-12-04
  • 1970-01-01
  • 1970-01-01
  • 2020-05-22
  • 1970-01-01
  • 1970-01-01
  • 2018-12-12
  • 1970-01-01
  • 2018-06-20
相关资源
最近更新 更多