Switch env variables to environment.ts
I would like to reduce some of the redundancy in mine environment.ts
, as many of my variables env
start with the same. So I wanted to do the following:
export const environment = {
base_url: '//www.myWebsite.co.uk/',
ws_base_url: this.base_url + 'ws',
download_base_url: this.base_url + 'download'
}
Instead of this:
export const environment = {
base_url: '//www.myWebsite.co.uk/',
ws_base_url: '//www.myWebsite.co.uk/ws',
download_base_url: '//www.myWebsite.co.uk/download'
}
But when I use environment.ws_base_url
, I don't get //www.myWebsite.co.uk/ws
but undefined/ws
. I'm just wondering if this really doesn't work or if I'm just missing something.
source to share
Since people are demonstrating more than one way to do this, I thought I might add another way.
environment = {}
environment.base_url= '//www.myWebsite.co.uk/'
environment.ws_base_url= environment.base_url + 'ws'
environment.download_base_url= environment.base_url + 'download'
Just something I saw with your first code, it looks like you didn't include "," in your environment declaration. Right after the base_url declaration:
base_url: '//www.myWebsite.co.uk/'
source to share