Angular2 routing - manual url navigation

戏子无情 提交于 2019-12-06 07:57:41

In the new router especification you need something like this:

router.navigateByUrl("/app");

or

router.navigate(['HomeComponent'], {relativeTo: route});

This is probably due to server configration. Your server may be redirecting to index.html for any error path or path after context.

You should configure your server to rewrite the path than redirect.

Provide more info on server code and server being used

SOLVED - My bootstrap was missing some content...I had

bootstrap(AppComponent, [
  ROUTER_BINDINGS,
  bind(APP_BASE_HREF).toValue(location.pathname),
  bind(LocationStrategy).toClass(PathLocationStrategy )
  ]);

however this was incorrect, manually inputting:

bootstrap(AppComponent, [
  ROUTER_BINDINGS,
  bind(APP_BASE_HREF).toValue("/"),
  bind(LocationStrategy).toClass(PathLocationStrategy )
  ]);

Seemed to work. Thank you all for your help!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!