问题描述
I am having one model(login.model.ts) in my angular project like below -
export class LoginModel{
public uName: string;
public uPassword: string;
}
I want to use this model as input parameter in method called 'login' in my service(authentication.service.ts) from where I am doing **POST** request. How can I do that? May be something like below.
login(LoginModel lm){
//my post request here
}
在此登录方法中,想要使用“ lm.uName” /“ lm.uPassword”之类的
解决方法
您可以按照以下步骤进行操作。
login(lm: LoginModel){
//my post request here
}
,
因此,您必须使用loginModel类型来设置参数。所以
login(lm: LoginModel) {
// lm.uname = 'abc';
// logic here,api call
// etc
}