I'm creating a login page using Angular ...but I can't access the destination page after entering the login details. Given below is the code snippet of login.component.html file
<form *ngSwitchCase="'Login'">
<h3>Login</h3>
<label>Email:</label>
<br>
<input type="text" name="email" [(ngModel)]='email'>
<br>
<label>Password:</label>
<br>
<input type="password" name="pswd" [(ngModel)]="pswd">
<br>
<div class="foo">
<input class="btn btn-primary" type="button" value="Login" click="onClick()" >
<input class="btn btn-danger" type="button" value="Cancel" >
</div>
<button type="button" class="btn btn-info"(click)="swap()" >Not yet Registered?(Sign Up).</button>
and below is the code snippet of the component.ts file
import { Router } from '@angular/router';
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.css']
})
export class LoginComponent implements OnInit {
constructor(private router:Router) { }
ngOnInit(): void {
}
public val='Sign Up';
email:string;
pswd:string;
swap()
{
if(this.val=='Sign Up')
{
this.val='Login';
}
else
{
this.val='Sign Up';
}
}
onClick():any{
if(this.email=="sheldonCooper@yale.edu" && this.pswd=="theSkinnyWeirdo")
{
this.router.navigateByUrl('/list');
}
else
{
window.alert("Incorrect Email or Password!");
}
}
}````
Also the url doesn't change when I click the login button.
Please provide a quick fix for this.