Installing Angular 2 RC2 w/ new component router

2019-04-28 19:00发布

I'm probably missing something simple, but trying to use the new Component Router I can't get VS Code to recognize it.

I changed all my @angular references in package.json to 2.0.0-rc.2; ran npm install and VS Code doesn't like my imports:

enter image description here

When I navigate to the @angular/router folder in node_modules, and inspect the index.d.ts I see all the references for the RC1 router. Removed the @angular folder and installed again, same result.

4条回答
Lonely孤独者°
2楼-- · 2019-04-28 19:15

it is now at V3.RC1. So please update your package.json accordingly

"@angular/router": "3.0.0-rc.1",

You might also have to upgrade your application to Angular2.RC5 and change the way routing is done.

查看更多
仙女界的扛把子
3楼-- · 2019-04-28 19:18

If you just started to work with Angular router, I suggest you disregard RC1 router and start with the new router v3.

"@angular/router": "3.0.0-alpha.7"

Here is the documentation for Router v3.

查看更多
我只想做你的唯一
4楼-- · 2019-04-28 19:19

For the new release of angular rc2. The version of router to install is

"@angular/router" : "3.0.0-alpha.6" or "@angular/router" : "3.0.0-alpha.7"

The repo for the router is at https://github.com/angular/vladivostok . The docs on the site https://angular.io/docs/ts/latest/guide/router.html are on alpha.6. I would advice to go through the changelog to know about breaking changes when using alpha.7

查看更多
神经病院院长
5楼-- · 2019-04-28 19:23

The router is not maintained as a separate project anymore. It has been recently merged into Angular2 and the router is now in beta.. I would suggest you to use start using the beta by adding a dependency in your package.json file "@angular/router": "3.0.0-beta.2"

查看更多
登录 后发表回答