Search code examples
angularangular2-routingangular2-router3

How to parse url "localhost:3000/1234.xhtml" in Angular 2?


I have this situation where the links are generated by the backend like this with .xhtml extension. User can just visit this link which they are given and I need to get the 1234 from 1234.xhtml and query the database with that. Getting the query param is clear. But the router doesn't parse this url. It throws error saying "Cannot GET /1234.xhtml". Imperative routing does work. So this is a browser or server related problem. How to resolve this?

My route is:

{path:':id', component:SomeComponent},

enter image description here


Solution

  • So in the barebone application with Angular 2 running without backend, it was giving me this error. But as soon as I connected the backend. It works fine as intended.