Answers for "angular button to another page"

1

add a route to a buttoin in angular

<button type="button" class="btn btn-primary-outline pull-right" (click)="btnClick();"><i class="fa fa-plus"></i> Add</button>    

// myComponent.component.ts file 
import { Router } from '@angular/router';

constructor(private router: Router) {

}
// myComponent.component.thml
btnClick= function () {
        this.router.navigateByUrl('/user');
};
Posted by: Guest on February-09-2020
0

how click button and redirect angular

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);
  }
}
Posted by: Guest on November-30-2020

Code answers related to "angular button to another page"

Code answers related to "Javascript"

Browse Popular Code Answers by Language