angular - Routing doesn't work for me when doing a hard refresh -


i looking @ source code: https://github.com/angular/angular.io/blob/master/public/docs/_examples/toh-5/dart/lib/app_component.dart

and seems application route right when go root.

localhost:8080/

the routing updates move around application, seems if @ something: localhost:8080/dashboard in basecase, , hard refresh, fails. give me 404 not found! error.

it work find if do: localhost:8080/#!/dashboard not address passed application.

in index.html have: <base href="/">

my app_component.dart file follows:

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"; } 

it seems have routing working except this.

my desired end state doing: localhost:8080/detail/14 , open correct component. isnt done on fresh site reference as when navigating throughout application.

to switch hashlocationstrategy change providers to

bootstrap(appcomponent, [   heroservice,    router_providers,   provide(locationstrategy, useclass: hashlocationstrategy) ]) 

if want use pathlocationstrategy can use pub serve-wrapper https://pub.dartlang.org/packages/pub_serve_rewrites allows use pathlocationstrategy pub serve.

for deployment need configure webserver use there support html5 pushstate.


Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -