How should I configure the base href for Angular 2

2019-04-03 22:47发布

I need to either set <base> in the HTML or APP_BASE_HREF during the bootstrap for Angular 2 to not throw exceptions. If I set either of these then Electron, thinking in terms of the file system, throws exceptions in browser_adapter.ts when trying to match a route:

EXCEPTION: Error: Uncaught (in promise): Cannot match any routes. Current segment: 'C:'. Available routes: ['/dashboard', '/accounts'].

I tried using just the HashLocationStrategy mentioned in this blog post, but Angular still complains about the base href not being set.

1条回答
虎瘦雄心在
2楼-- · 2019-04-03 23:11

Since the href attribute can take a relative path and thanks to @DavidC and @ChristianRondeau in the comments on the question for verifying, it should work like this:

<base href="./">
查看更多
登录 后发表回答