AngularDart View没有正确路由

时间:2015-03-16 20:36:43

标签: dart angular-ui-router angular-dart

我是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时,我需要它来路由到网址路径:http://127.0.0.1:3030/BookingService/web/bookingservice.html#/reservations

但是,它实际路由到的网址是: http://127.0.0.1:3030/BookingService/web/BookingService/packages/BookingService/component/tab_menu.html#/reservations

这基本上将它带回到相同的视图而不显示我的homeReservation.html。

关于我可能遗失的任何指示/提示/建议?

谢谢!

1 个答案:

答案 0 :(得分:0)

我通过将我的索引名称从bookingservice.html更改为index.html来实现它。不确定为什么我需要一个index.html才能正常工作。如果有人有这背后的理由,请随时在下面评论。我会更多地挖掘原因。