问题
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