Angular 2 - 不是构造函数错误

时间:2017-02-14 14:51:49

标签: angular constructor model

我正在尝试创建一个类的实例。但是我得到了这个我无法解决的错误:

  

models.MyTimeDefinition不是构造函数

我的 models.MyTimeDefinition

Import { Injectable } from "@angular/core";

@Injectable()
export class MyTimeDefinition {
    RequestCodes: Array<RequestCodes>;
    BalanceCodes: Array<BalanceCodes>;

    Description: {
        SelectedLanguage: number,
        Values: any
    };

    ID: number;
    DescriptionID: number;

    Info: {
        CreationUser: string,
        CreationDate: string,
        LastChangedUser: string,
        LastChangedDate: string,
        Info: string
    };

    IsDataLoaded: boolean;
    TypeName: string;


    constructor(userLanguage: number, languages: any) {
        this.RequestCodes = [];
        this.BalanceCodes = [];
        this.ID = 0;
        this.DescriptionID = 0;
        this.Info = { CreationUser: null, CreationDate: null, LastChangedUser: null, LastChangedDate: null, Info: null };
        this.Description = { SelectedLanguage: userLanguage, Values: null };
        this.TypeName = "MyTimeDefinitionDetailViewModel";
    }
}

这是我为运行构造函数而创建的调用

public createNewMyTimeDefinition() {
this.definitionDetails = new models.MyTimeDefinition(this.definitionData.UserLanguage, this.definitionData.Languages);
    }

提前感谢您的帮助!

0 个答案:

没有答案