I tried to use the router in angular2-beta.20 in Dart with the HashLocationStrategy. But I couldn't find any docs, except for this link to angular2-beta.15 docs, which are incomplete. The example shows TypeScript imports instead of Dart ones.
So I tried to import package:angular2/router.dart
, but the Dart Analyzer keeps complaining that it can not find LocationStrategy
and HashLocationStrategy
Also I don't know, how to write the import exactly, because a top-level provide function, as in the example above, seems non existent.
provide(LocationStrategy, {useClass: HashLocationStrategy})
After some research I found the following:
LocationStrategy
andHashLocationStrategy
are now part ofpackage:angular2/platform/common.dart
instead ofpackage:angular2/router.dart
.The
bootstrap()
- method is platform specific, so we need to importpackage:angular2/platform/browser.dart
.We need to import
package:angular2/router.dart
to haveROUTER_PROVIDERS
available inbootstrap()
method.Here is a working code example for the dart file initializing :
Hope this helps somebody! :)