Home > Enterprise >  How to create a "confirm" button in a modal with a redirect path
How to create a "confirm" button in a modal with a redirect path

Time:02-21

I created a modal, when the user clicks on confirm, I would like the user to be redirected to the page => securities-in-portfolio.

modal

<div >
     <button type="button"  (click)="confirm()">
          Confirm
     </button>
</div>

Do you know how to write this in TS, please?

CodePudding user response:

Yep. in your component file. You have to have a method named confirm. it looks like:

constructor(private readonly router: Router // -> add this) {}

confirm() {
   this.router.navigateByUrl('/ROUTE_TO_SECURITIES_IN_PORTFOLIO'); 
}

CodePudding user response:

Try routerlink

Instead of

(click)="confirm()"

Use

[routerLink]="['/securities-in-portfolio']"
  • Related