我有2个课程UserLogic
和UserModel
我想在UserModel
构建器中访问UserLogic
的方法...我该怎么做?
import { UserModel, ItUser } from '../../models/user.model';
export class UserLogic {
public user: ItUser;
constructor() {
//UserModel is singleton class
this.user = UserModel.model().user;
console.log(this.user);
}
}
答案 0 :(得分:0)
我想在UserLogic构造函数中访问UserModel的方法......我该怎么做
根据您的代码,您可以访问UserModel
的实例。所以只需调用方法,例如foo
:
import { UserModel, ItUser } from '../../models/user.model';
export class UserLogic {
public user: ItUser;
constructor() {
this.user = UserModel.model().user;
// Just call the method. eg.
this.user.foo();
}
}