angular2 Routing issue with pathmatch

混江龙づ霸主 提交于 2020-01-25 12:59:30

问题


So I decided to retry the angular2 tutorial, since last time I had some issues with the router (sound familiar?). See link: Angular 2 tutorial Where I followed every step, got everything to work, until I got to the redirect section.

{
  path: '',
  redirectTo: '/dashboard',
  pathMatch: 'full'
},

Where it hangs on the "pathMatch". Even when I try to restart with "npm start" in the command window, I get this error:

app/app.routes.ts(11,5): error TS2322: Type '({ path: string; redirectTo: string; pathMatch: string; } | { path: string; component: typeof Das...' is not assignable to type 'Route[]'.

My router version defined in package.json is: "@angular/router": "3.0.0-alpha.7", of which i thought was the latest version?

How can I check which routerversion is actually installed on my project/pc? I'm kind of new to the whole npm-deal and I'm getting stumped trying to figure this thing out. I'm guessing I may have an old router version?

Thanks in advance for helping me out.


回答1:


Okay I guess you should have found the answer by now, but here is how you can check which version of router is installed on your system

Go into node_modules folder and then into @angular, and into router

node_modules/@angular/router
├── README.md
├── bundles
├── index.d.ts
├── index.js
├── index.js.map
├── index.metadata.jsenter code hereon
├── package.json <----------- This file should tell you the Version
├── src

I hope your problem was solved. Thanks.



来源:https://stackoverflow.com/questions/38701605/angular2-routing-issue-with-pathmatch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!