【发布时间】:2015-03-16 20:36:43
【问题描述】:
我是 Dart 新手,我的视图/路由器有一些问题。
lib/routing/booking_service_router.dart 中的路由器:
void bookingServiceRouteInitializer(Router router, RouteViewFactory views) {
views.configure({
'reservations': ngRoute(
path: '/reservations',
view: 'view/homeReservation.html')
});
}
主要模块bookingservice.dart:
class BookingServiceModule extends Module {
BookingServiceModule() {
bind(ReservationHome);
bind(TabMenu);
bind(RouteInitializerFn, toValue: bookingServiceRouteInitializer);
bind(NgRoutingUsePushState, toValue: new NgRoutingUsePushState.value(false));
}
}
void main() {
Logger.root.level = Level.FINEST;
Logger.root.onRecord.listen((LogRecord r) { print(r.message); });
applicationFactory().addModule(new BookingServiceModule()).run();
}
主要的html bookingservice.html:
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>BookingService</title>
<link rel="stylesheet" href="bookingservice.css">
</head>
<body>
<tab-menu ng-cloak></tab-menu>
<div>
<section>
<ng-view></ng-view>
</section>
</div>
<script type="application/dart" src="bookingservice.dart"></script>
<script type="text/javascript" src="packages/browser/dart.js"></script>
</body>
</html>
和/lib/component/tab_menu.html:
<link rel="stylesheet" href="tab_menu.css">
<div>
<ul>
<li>
<a href="#/reservations">click this</a>
</li>
</ul>
</div>
最后是我试图路由到 web/view/homeReservation.html 的视图:
<div>
<h1>Hello!</h1>
</div>
当我单击链接以路由到 homeReservation.html 时,我需要它路由到 url 路径:http://127.0.0.1:3030/BookingService/web/bookingservice.html#/reservations
但是,它实际路由到的 url 是: http://127.0.0.1:3030/BookingService/web/BookingService/packages/BookingService/component/tab_menu.html#/reservations
这基本上把它带回到同一个视图,而不是显示我的 homeReservation.html。
关于我可能缺少什么的任何指针/提示/建议?
谢谢!
【问题讨论】:
-
看起来类似于github.com/angular/angular.dart/issues/1599,它似乎已修复但未发布。您可以尝试将依赖项添加到 git repo 而不是托管包。
-
bookingservice.html 是您的索引吗?如果是这样.... ng-app 在哪里?
-
添加了 ng-app,但还是同样的问题。
标签: dart angular-ui-router angular-dart