Search code examples
angularmodelhttpservice

How to pass model as input parameter in method in Angular10?


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
}

And inside this login method want to use like 'lm.uName' / 'lm.uPassword'


Solution

  • You can do it like below.

    login(lm: LoginModel){
      //my post request here
    }