【发布时间】:2017-07-13 22:45:46
【问题描述】:
当我转到根目录时,我的应用程序似乎会立即路由。
本地主机:8080/
当我在我的应用程序中移动时,路由会更新,但似乎如果我遇到以下情况:localhost:8080/dashboard 在基本情况下,并进行硬刷新,它会失败。它会给我一个404 not found! 错误。
如果我这样做,它只会找到:localhost:8080/#!/dashboard,但这不是传递给我的应用程序的地址。
在 index.html 中我有:<base href="/">
我的 App_Component.dart 文件如下:
import 'package:angular2/angular2.dart';
import 'package:angular2/router.dart';
import 'hero_component.dart';
import 'heroes_component.dart';
import 'dashboard_component.dart';
import 'hero_service.dart';
@Component(
selector: "my-app",
directives: const [ROUTER_DIRECTIVES],
providers: const [HeroService, ROUTER_PROVIDERS],
templateUrl: "app_component.html")
@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";
}
看来我的路由适用于除此之外的所有内容。
我想要的最终状态是:localhost:8080/detail/14,它会打开正确的组件。与浏览整个应用程序时相比,现在在新的站点参考上没有这样做。
【问题讨论】:
标签: angular angular-dart angular2-routing