我試圖讓routerLink
指令使用矩陣參數。到目前爲止,我能夠工作的唯一語法變體就是路徑字符串。用於routerLink指令的角度2路由器替代語法不起作用
<a routerLink="/state-scratchpad">Syntax 1 - works</a>
<a routerLink="['/state-scratchpad']">Syntax 2 - doesn't work</a>
<a routerLink="['/state-scratchpad', { tcomp: '1', tmake: '1-7' }]">Syntax 3 - doesn't work</a>
<a routerLink="/state-scratchpad;tcomp=1;tmake=8">Syntax 4 - doesn't work</a>
在URL欄中導航到/state-scratchpad;tcomp=1;tmake=8
也適用。
這裏是我的路線:
const routes = [
{ path: '', pathMatch: 'full', redirectTo: '/welcome' },
{ path: 'welcome', component: WelcomeComponent },
{ path: 'state-scratchpad', component: StateScratchpadComponent, params: { tcomp: '', tmake: '' } }
];
我採用了棱角分明2.0.0
。根據angular.io站點上的文檔,routerLink
值的各種語法都應該工作。但只有最簡單的語法纔有效。由此產生的錯誤消息:
S1: Works
S2: Error: Cannot match any routes: '%5B'/state-scratchpad'%5D'
S3: Error: Cannot match any routes: '%5B'/state-scratchpad'%2C%20%7B%20tcomp%3A%20'1'%2C%20tmake%3A%20'1-7'%20%7D%5D'
S4: Error: Cannot match any routes: 'state-scratchpad%3Btcomp%3D1%3Btmake%3D8'
任何想法?
的PARAMS難道不該'[routerLink] = 「...」'? – jonrsharpe