有人能说出我需要在角度4中声明用户模型吗?

时间:2017-09-01 09:31:33

标签: angular typescript

这是我的用户模型,是否正确?我可以添加方法????

export class User {
  id: number;
  login: string;
  hash: string;
  salt: string;
  fname: string;
  lname: string;
  sname: string;
  phone: string;
  addTime: string;
  isActive: boolean;
}

1 个答案:

答案 0 :(得分:1)

这只是我复制的原型

export class Model{ //something like this for getter and setters and also other methods 
    private _keyValue: number;
    private _computedValue: number;

    getKeyValue(): number{
        return this._keyValue;
    }

    setKeyValue(value: number){
        this._keyValue = value;
    }

    getComputedValue(): number{
        return this._computedValue;
    }
    customeMethod(){}
}