-2

I'm looking for some help regarding the use of dynamic words in my Base URL.

Consider for example Slack. If i write abcd.slack.com it finds a work space name abcd and redirects me to the login page of the work space. I need a similar implementation in my Angular website. I don't know how to implement such thing. In Angular routing i can only provide the paths which comes after the base URL. How can i implement such thing that also works on my production environment.

For example This is the usual URL in our development environment http://localhost:4200/signin

Can i do something like this

http://xxxx.localhost:4200/signin

where i can set xxxx as my dynamic data to perform some backend queries

I think is the same as abcd.slack.com

Saad Ashfaq
  • 188
  • 1
  • 2
  • 12
  • So what exactly is the problem??? What have you actually tried,and what specific problems did you encounter? Please update your post with an [mcve] and/or more .details – paulsm4 Jan 22 '19 at 06:25
  • I haven't tried anything. I just found a similar thing happening in Slack, that's what i need in my website. I don't even know where to start. – Saad Ashfaq Jan 22 '19 at 06:30

1 Answers1

0

Use window.location to redirect to URL other than routes defined by angular application:

window.location.href = 'http://google.com';
Saddam Pojee
  • 1,518
  • 9
  • 14
  • Can you elaborate with an example on how to use this URL or some word in the URL to render a component in Angular? Can we put if/else condition in our Routes? – Saad Ashfaq Jan 22 '19 at 07:43
  • @SaadAshfaq I thought you need dynamic base URL. Usually that is done inside some business logic code and not with routes. If you want to do it with routes, you can follow this answer: https://stackoverflow.com/a/40421975/10699402 – Saddam Pojee Jan 22 '19 at 08:18
  • Yes. Definitely i need dynamic base URL, but based on that i need to render some component as well. You can see Slack as an example. I've explained it's working above. – Saad Ashfaq Jan 22 '19 at 09:47
  • I've updated the question. Maybe now it can help you understand what i'm asking for. – Saad Ashfaq Jan 22 '19 at 12:51