What are Router Bindings actually used for

拜拜、爱过 提交于 2020-01-03 07:00:08

问题


What are Router Bindings actually used for in Angular2 router. specially the Router 3.0 (newest Angular RC4 router)? Any working code or plunker?

https://angular.io/docs/ts/latest/api/router-deprecated/index/ROUTER_BINDINGS-let.html


回答1:


The name was just changed from ROUTER_BINDINGS to ROUTER_PROVIDERS as were the bindings parameter of the @Component(), @Directive() or @Pipe() decorator was renamed to providers and they actually are the router implementation and services provided by the router implementation to be used injected in your code.

In the current version this feature is exported as function provideRouter()

It looks like ROUTER_PROVIERS is going to be renamed again to RouterModule or similar with the introduction of modules in RC.5.




回答2:


The main point is that the old "router bindings" are deprecated. In new (Angular2/Router 3) code going forward, you should instead use "routing providers".

Here's a great article that describes the current routing model:

Routing in Angular2 Revisited

You might also find this article helpful:

Introduction to Angular 2 Routing

Finally, there's the Angular2 documentation itself:

https://angular.io/docs/ts/latest/guide/router.html



来源:https://stackoverflow.com/questions/38681207/what-are-router-bindings-actually-used-for

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