angular: New tab opened with target="_blank" is throwing HTTP Status 404 error
Current behavior
opening new tab is throwing HTTP Status 404 error on page. Below given is the html template code
Found below error in browser console “Failed to load resource: the server responded with a status of 404 (Not Found)”
Expected behavior It should not throw error and new tab should be loaded as per component template
Minimal reproduction of the problem with instructions
- Create angular2 webpack project
- Create a component as a.component.ts
- Create a component as b.component.ts
- Provide routing to Component b in component “a” template as below
<a class="left-header-images-link" routerLink="/test" target="_blank">
- Click on the router link above and the new tab displayed is showing 404 error
What is the motivation / use case for changing the behavior?
Please tell us about your environment:
Operating System : Windows7
- Angular version: 2.0.X
Angular 2.4.6 and webpack 2.2.1
- Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
Chrome:56 IE:11
- Language: [all | TypeScript X.X | ES6/7 | ES5] TypeScript:2.1.6 ES5
- Node (for AoT issues):
node --version
=
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 18 (8 by maintainers)
Thank you all for your inputs.
I finally found a solution to my issue by setting { useHash: true }. I don’t know why it doesn’t work when useHash property of router module is not set to true. I believe it should work in both ways.