Extending the to-do list
We can keep index.html
as is and start by adding routing to our main.dart
file:
// web/main.dart moduleRouteInitializer(Router router, RouteViewFactory views) { views.configure({ // This route will be displayed even when no path is set. 'add': ngRoute( defaultRoute: true, path: '/add', view: 'view/add.html'), // Detail of a task identified by its id. 'detail': ngRoute( path: '/detail/:taskId', view: 'view/detail.html'), }); } class MyAppModule extends Module { MyAppModule() { bind(TodoListComponent); bind(TodoDetailComponent); // Initialize routes. bind(RouteInitializerFn, toValue: moduleRouteInitializer); // Turn on listening to Window.onHashChange event. bind(NgRoutingUsePushState, toValue: new NgRoutingUsePushState.value(false)); } }
In this case, route paths are paths after the hash sign in your URL. That's, for example, index.html#/add
or index.html#/detail/3
. However...