问题
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 here
on
├── 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