What is the difference between [routerLink]
and routerLink
? How should you use each one?
相关问题
- 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
Assume that you have
It means that clicking Recipes hyperlink will jump to http://localhost:4200/recipes
Assume that the parameter is 1
It means that passing dynamic parameter, 1 to the link, then you navigate to http://localhost:4200/recipes/1
You'll see this in all the directives:
When you use brackets, it means you're passing a bindable property (a variable).
So this variable (routerLinkVariable) could be defined inside your class and it should have a value like below:
But with variables, you have the opportunity to make it dynamic right?
Where as without brackets you're passing string only and you can't change it, it's hard coded and it'll be like that throughout your app.
UPDATE :
The other speciality about using brackets specifically for routerLink is that you can pass dynamic parameters to the link you're navigating to:
So adding a new variable
Updating the [routerLink]
When you want to click on this link, it would become: