https://angular.io/api/router/RouterLink gives a good overview of how to create links that will take the user to a different route in Angular4, however I can't find how to do the same thing programmatically rather needing the user to click a link
相关问题
- Angular RxJS mergeMap types
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- Backbone.js PushState routes .htaccess only workin
- How to update placeholder text in ng2-smart-table?
- How to instantiate Http service in main.ts manuall
相关文章
- angular脚手架在ie9+下兼容问题
- angular 前端项目 build 报错 "Cannot find module 'le
- Angular Material Stepper causes mat-formfield to v
- After upgrade to Angular 9 cannot find variable in
- is there any difference between import { Observabl
- Suppress “Circular dependency detected” suppress w
- How can you get current positional information abo
- Angular material table not showing data
navigateByUrl
routerLink
directive as used like this:is just a wrapper around imperative navigation using
router
and its navigateByUrl method:as can be seen from the sources:
So wherever you need to navigate a user to another route, just inject the
router
and usenavigateByUrl
method:navigate
There's another method on the router that you can use - navigate:
difference between the two
Read more in the official docs.
In addition to the provided answer, there are more details to
navigate
. From the function's comments:The Router Guide has more details on programmatic navigation.