Here is my HTML code:
<form>
<input id = "username" type="text" name="username" ngModel placeholder="username">
<input id = "password" type="password" name="password" ngModel placeholder="password">
</form>
<button name="buttonLogin" type="button" (click)="login()" style="height:30px; width:100px;">Login</button>
Here is my component.ts file code:
export class AuthComponent implements OnInit {
username: any;
password: any;
login(){
this.authService.login(this.username,this.password).subscribe(data=>console.log('login
successful'));//email pass will be fetched from text boxes
}
}
I have tried many ways to get input from the text field into the component.ts file variables. but no method works. I am working on frontend as well as backend. This is the authorization part. If i pass username and password values directly in the component.ts file then the login is successful all the way to the backend and the database. But when I try to get variables of the input text fields in the html file then it doesn't work.
Please have a look, thanks.