1

Background: I would like all routes to be added a prefix by a service fired at startup.

The app is to access information about some events e.g. AngularCodeWeek2015, NodeJSRetreat2017, ... so the URLs should be of the format http://www.eventsapp.com/<event_name>

The event_name prefix is to act as a url parameter but we would like to have it as the first part of all paths rather than something like http://www.eventsapp.com/?event=<event_name>

(The Angular App is getting its data from Dreamfactory and the event_name will be used to retrieve the right API_KEY, which is different for each event. So at startup, Angular should retrieve the API_KEY using the event_name found in the URL and then get the relevant data for this event).

Question: After startup, the prefix is supposed to remain the first part of all paths. Yet, because the prefix is dynamically set, would there be a way to either add it to all paths at startup or make the angular router somehow 'ignore' it?

Aurelien Giraud
  • 128
  • 2
  • 12
  • you mean there is some information in `url` and you just want that ? ignoring `prefixes` is Ok ? right ? – Muhammad Usman Nov 09 '17 at 17:57
  • why use angular for this? use a classic – Phil Nov 09 '17 at 18:44
  • Clarification: the prefix should be like a fake folder on the server. @UsmanRana: yes, the angular app should ignore the prefix. The prefix would just be read by the app at startup to get hold of the right API key, but then it should remain in the url through the whole app navigation. – Aurelien Giraud Nov 10 '17 at 08:11
  • @Phil: do you mean setting ? Then what does it mean exactly to bootstrap angular with the static prefix? – Aurelien Giraud Nov 10 '17 at 08:28
  • 1
    @Phil: searching for solutions using your comment, I have found https://stackoverflow.com/questions/38112891/set-base-href-dynamically-angular-2-4 The scenario is very similar and the answers there probably answer my question (I still have to try it out) – Aurelien Giraud Nov 10 '17 at 09:37

0 Answers0