What's the proper way to set a Router & RouterLink in Angular2 Dart
As of Angular Dart 2.0.0 (release candidate), the correct syntax for a router link is:
<a [router-link]="['./Home']">Go Home</a>
The value is a list of arguments that are passed to Router.navigate()
.
The correct syntax for configuring routes is:
@Component(
selector: 'my-app',
template: ...,
directives: const [ROUTER_DIRECTIVES],
providers: const [HeroService, ROUTER_PROVIDERS])
@RouteConfig(const [
const Route(
path: '/dashboard',
name: 'Dashboard',
component: DashboardComponent,
useAsDefault: true),
const Route(
path: '/detail/:id', name: 'HeroDetail', component: HeroDetailComponent),
const Route(path: '/heroes', name: 'Heroes', component: HeroesComponent)
])
class AppComponent {
String title = 'Tour of Heroes';
}