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

Issue

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 class="modal-footer justify-content-center">
     <button type="button" class="btn btn-primary" (click)="confirm()">
          Confirm
     </button>
</div>

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

Solution

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'); 
}

Answered By – Anh Le

Answer Checked By – Willingham (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.