我有一个类似下面的User
类,可以正常工作。现在,我也想将他的Post[]
构造为实际的Post类,但是我不知道该怎么做。
export class User {
private _id: number;
private _name: string;
private _email: string;
private _posts; <--------------
public constructor(data?: Partial<User>) {
Object.assign(this, data);
}
Getters and setters
}
答案 0 :(得分:0)
尝试
export class User {
private _id: number;
private _name: string;
private _email: string;
private _posts: Any[];
public constructor(data?: Partial<User>) {
Object.assign(this, data);
}
Getters and setters
}