Search code examples
angularrouterrouterlink

Configurate RouterLink in a botton


I'm practicing Angular 2, and configured a button with a password entered and a correct one to redirect to a second page. I configured the routing but I do not know how to do it so that it is validated and then redirected.

What I currently have configured in the following but I can not click the button and I would like to redirect to the second page.

enter image description here

enter image description here

enter image description here


Solution

  • Why are you having both routerLink and click on the same button. you can instead move the routerLink to the code as

    validarpass(pass:number) {
        .....
        this.router.navigate(['/component-one']);   
    }
    

    Inject the Router to your constructor as below

    constructor(private router:Router){
    ...}