Werner Swart
Werner Swart

Reputation: 470

Angular2 and Typescript Definitions

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?

Upvotes: 1

Views: 2379

Answers (2)

Evan Plaice
Evan Plaice

Reputation: 14140

This was changed in [email protected]

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:

Upvotes: 0

TGH
TGH

Reputation: 39278

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

Upvotes: 1

Related Questions