Как нажмите кнопку и перенаправить Angular
<a class="btn" routerLink="/votes">Check votes</a>
Bloody Beetle
<a class="btn" routerLink="/votes">Check votes</a>
import { Component } from '@angular/core';
import { Router } from '@angular/router';
// component details here...
export class MyComponent {
constructor(private router: Router){ }
goToVotes($myParam: string = ''): void {
const navigationDetails: string[] = ['/votes'];
if($myParam.length) {
navigationDetails.push($myParam);
}
this.router.navigate(navigationDetails);
}
}
<button class="btn" (click)="goToVotes()">Check votes</button>