typescript - Angular2 parameter URL not working when visited directly -
i have configured angular2 routes parameters. when visit /censo/119 or /viaje/119 1 of [routerlink] i've defined works fine. when go directly url http://localhost:3000/censo/119 404.
i'm using lite-server development app.
am missing configuration? need use different server?
this app.routes.ts
const routes: routerconfig = [ { path: '', component: censocomponent }, { path: 'censo', component: censocomponent }, { path: 'viajes', component: viajescomponent }, { path: 'censo/:viaje', component: censodetailcomponent }, { path: 'viajes/:viaje', component: viajesdetailcomponent }, ]; and routerlinks
<a [routerlink]="['/censo']">censo</a> <a [routerlink]="['/viajes']">viajes</a> <a [routerlink]="['/censo',119]">censo 119</a> <a [routerlink]="['/viajes',119]">viaje 119</a> <router-outlet></router-outlet> edit
i've added bs-config.json i'm getting same behavior.
{ "port": 8000, "files": ["./**/*.{html,htm,css,js}"], "server": { "basedir": "." } } and project structure, in case helps.
thanks
you should run lite-server command same location index.html. default behavior serves content current folder, opens browser, , applies html5 fallback index.html.
if reason cannot execute command folder , index.html resides in src map child of folder execute lite-server from, should add bs-config.json file server , baseurl property this:
{ "server": { "basedir": "./src" } } and run lite-server this, depending on filename of config, , on location:
lite-server -c ./bs-config.json 


Comments
Post a Comment