-1

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

Gary
  • 2,293
  • 2
  • 25
  • 47

2 Answers2

2

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.

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • Then how do you bind( APP_BASE_HREF).toValue('/') in the new router – Gary Jul 31 '16 at 10:49
  • 2
    bootstrap(AppComponent, [{provide: APP_BASE_HREF, useValue: '/'}])`. The imports have changed a bit as well. See http://stackoverflow.com/questions/36861628/location-and-hashlocationstrategy-stopped-working-in-beta-16/36861629#36861629 – Günter Zöchbauer Jul 31 '16 at 10:52
1

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

paulsm4
  • 114,292
  • 17
  • 138
  • 190