1

I am using the typescript definitions installed with tsd to work with Angular2's preview. Recently they have released 2.0.0-alpha.40 and now my routing doesn't work anymore. I have taken a look at the examples on angular's site and they are referencing for example routerBindings from angular2/router, but the current angular2/router does not define this function. I did ran an update and a reinstall with tsd but nothing changes. How do I know if the angular2 typescript definition published are up to date with the javascript version releases?

Evan Plaice
  • 13,944
  • 6
  • 76
  • 94
Werner Swart
  • 371
  • 2
  • 4
  • 13
  • 1
    [They stopped using tsd](https://github.com/angular/angular/blob/717bd23c37f0c8aa7a30ff221671a09a2629375f/CHANGELOG.md) from alpha-41. `typings: *.d.ts files are now bundled with npm package, tsd link or tsd install no longer needed`. – Jesse Good Oct 13 '15 at 21:28
  • As Jesse said, it comes with npm package now https://docs.google.com/document/d/1LvPBh7yxmjr7N1vCQ-kBj4guZGfGLBiz44CfenOX6o0/mobilebasic?pli=1&viewopt=127 – lame_coder Oct 14 '15 at 00:08
  • Thanks guys, appreciated. – Werner Swart Oct 14 '15 at 05:34

2 Answers2

1

Just get the typings via npm install

Put this in your package.json:

"angular2": "^2.0.0-alpha.42"

Among other things - they have renamed routerBindings to ROUTER_PROVIDERS.

Here is an updated write-up of routing in Angular 2.0: http://www.syntaxsuccess.com/viewarticle/routing-in-angular-2.0

You can see working samples here:http://www.syntaxsuccess.com/viewarticle/angular-2.0-examples

TGH
  • 38,769
  • 12
  • 102
  • 135
  • The samples you linked to use `HashLocationStrategy` which is only used to match fragments (ex `/url/path#fragment`). – Evan Plaice Oct 31 '15 at 07:00
0

This was changed in angular@2.0.0-alpha.41

routerInjectables was renamed to ROUTER_BINDINGS

ROUTER_BINDINGS was then renamed to ROUTER_PROVIDERS

Use ROUTER_PROVIDERS

It includes:

  • RouteRegistry - the registry of defined routes
  • LocationStrategy = PathLocationStragety - match routes by path

This is basically a shortcut to bootstrap your Router with a default setup.

For example:

@Component ({
...
})
@View ({
...
})
@RouteConfig ({
...
})
class App {}

bootstrap(App, [ ROUTER_PROVIDERS ]);

Sources:

Evan Plaice
  • 13,944
  • 6
  • 76
  • 94