Angular4 / TypeScript类的可用性

时间:2018-09-27 13:46:22

标签: javascript angular typescript

是否可以访问两个不同的Typescript类(例如,控制器)来存储值...这是我的用例...。 我从前端获取价值,可以说我有ID="100",Name="Angular4"。现在如何使用get getFieldValue(fieldName: string)setFieldValue(fieldValue: string, value: string)方法将这些值传递给这些类。我也尝试实例化类以获取或设置值,但是我失败了,有人可以告诉我如何使用打字稿完全实现所需的输出吗?

我的课程是:

主班

import {Record} from './record';
import {Field} from './field';
export class BusinessObject {

    public boName: string = null;
    public focusedRecordsList = new Set();
    // public activeRecord: Record = new Record();
    public fetchSize: number = 100;
    // public activeParentRecord: Record = new Record();
    public hasMoreRows: boolean;
    public isPageQuery: boolean;
    public startIndex: number;



    public createNewRecord(boName: string, parentId: string, fromRecord: string) {
        return JSON.stringify({'boName': boName, 'parentId': parentId, 'fromRecord': fromRecord});
    }

getFieldValue(fieldName: string): any {

}

    setFieldValue(fieldValue: string, value: string): void {

    }

}

和另一个类,其中包含我的字段类型

import {BusinessObject} from './business-object';
export class Field extends BusinessObject{

     // Specifies different information on the field
     public name: string    = null;
     public id: string      = null;
     public type: string    = null;
     public boId: string    = null;
     public colName: string = null;



     constructor(name: string) {

     }


}

0 个答案:

没有答案