Angular4 - routerLink with typescript

0 votes

I have worked with routerLink and it works very well :

      <a routerLink="inscription" class="btn btn-default">Inscription</a>
      <a routerLink="login" class="btn btn-default">Se connecter</a>

I am trying now to deal with routerLink inside the typescript file. Exactly, when I click on a button, I call a function inside this function I want to call routerLink how could I do it? and if is calling it will reload the page or it will work exactly the same as the routerLink above ?

Jun 16, 2022 in TypeSript by Logan
• 2,140 points
2,377 views

1 answer to this question.

0 votes

In code, you use .navigate instead:

this.router.navigate(['/products']);

You pass it the same parameter as you do the routerLink.

enter image description here

answered Jun 22, 2022 by Nina
• 3,060 points

Related Questions In TypeSript

0 votes
1 answer

how to use spread syntax and new Set() with TypeScript

The ... operator should work on anything ...READ MORE

answered Jun 10, 2022 in TypeSript by Nina
• 3,060 points
490 views
0 votes
1 answer

How to use useState hook in React with TypeScript correctly?

Without any initial argument, the type of email and setEmail will ...READ MORE

answered Jun 10, 2022 in TypeSript by Nina
• 3,060 points
1,921 views
0 votes
1 answer

How to import library with TypeScript Playground

TypeScript Playground isn't a fully fledged sandbox ...READ MORE

answered Jun 13, 2022 in TypeSript by Nina
• 3,060 points
3,038 views
0 votes
1 answer
0 votes
1 answer

How to set meta tags using Angular universal SSR and ngx-seo plug-in?

first Install the plug-in with npm i ngx-seo ...READ MORE

answered Feb 11, 2022 in Others by narikkadan
• 63,600 points
2,208 views
0 votes
1 answer

Can't bind to 'ngModel' since it isn't a known property of 'input'

Just add this in the app.module.ts file: import { FormsModule ...READ MORE

answered Apr 30, 2022 in Other DevOps Questions by narikkadan
• 63,600 points
4,434 views
0 votes
1 answer

VS Code enforces semicolons, but why doesn't Angular and TypeScript not use it consistently?

JavaScript has a syntactic feature known as semicolon ...READ MORE

answered May 31, 2022 in TypeSript by Nina
• 3,060 points
4,836 views
0 votes
1 answer

Square brackets around vs after expression in Typescript

x is an Array, while y is a Tuple. The ...READ MORE

answered Jun 7, 2022 in TypeSript by Nina
• 3,060 points
3,778 views
0 votes
1 answer

Interface type check with Typescript

You can achieve what you want without ...READ MORE

answered May 31, 2022 in TypeSript by Nina
• 3,060 points
5,840 views
0 votes
1 answer

Customise Ngx-toastr in angular 6 with TypeScript

After Override this CSS in your Style.css File. I ...READ MORE

answered Jun 9, 2022 in TypeSript by Nina
• 3,060 points
3,295 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP