When would you surround routerLink in square brackets?

When you put square brackets around routerLink (or any Angular binding) it will evaluate what you pass to it as a JavaScript expression. If you don’t put square brackets around routerLink it will take what you pass it as a literal string.

So if you want to pass an array to routerLink or evaluate a variable then you would have to use square brackets. If you want to pass a string you could either do

<a routerLink="/path">

OR

<a [routerLink]="'/path'">

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)