justinfagnani / route

A client + server routing library for Dart
BSD 3-Clause "New" or "Revised" License
114 stars 40 forks source link

Can not get /article/:articleID example to work #64

Closed delaneyj closed 10 years ago

delaneyj commented 10 years ago
<!DOCTYPE html>

<html>
  <head>
    <title>testRoutes</title>
  </head>

  <body>   
    <p id="info"></p>
    <script type="application/dart">
    import 'dart:html';
    import 'package:route_hierarchical/client.dart';
    var info = querySelector("#info") as ParagraphElement;
    var router = new Router();
    main() {
      router.root
        ..addRoute(name: 'article', path: '/article/:articleId', enter: showArticle)
        ..addRoute(name: 'home', path: '/', enter: showHome, defaultRoute: true);
      router.listen();
    }

    void showHome(RouteEvent e) {
      info.innerHtml = "In showHome<br>${router.url("article")}";
    }

    void showArticle(RouteEvent e) {
      var articleId = e.parameters['articleId'];
      info.innerHtml = "In showArticle $articleId";
    }

    </script>
    <script src="packages/browser/dart.js"></script>
  </body>
</html>

Tried

#/article/1234
#article/1234
#/article
#/article/
#/article/null
#/article/1234/

all with no luck.

pavelgj commented 10 years ago

try:

var router = new Router(useFragment: true);
delaneyj commented 10 years ago

Great! The example should probably be updated or comments to explain why this is needed.