As I work with my regular angular 4 app, I often find myself using Router, ActivatedRoute.params.subscribe, [routerLink], and other tools to navigate between pages and interpret URLs.
This results in a multitude of "magic strings" scattered throughout various .ts files. While this approach technically works because the strings match up, it feels messy and intertwined. Here's an example:
<a [routerLink]="['/foo']">Home</a>
<a [routerLink]="['/foo/item', 1]">Item 1</a>
<a [routerLink]="['/foo/item', 2]">Item 2</a>
One solution I considered is creating a service dedicated to building URLs for components, thereby centralizing knowledge of the URL structure. However, as someone relatively new to Angular, I'm not sure if using "magic strings" might actually be preferred for some reason.
Is there a recommended best practice for keeping URL structure separate from components?