3

I want to define global constant variable for my API url, which I want to access at many places.

In what type of file it will defined, and how to access them.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Anand agrawal
  • 492
  • 6
  • 25

1 Answers1

9

Use the files environment.ts and environment.prod.ts (for production) to define all your global const and call them like this :

environment.ts

export const environment = {
  apiVersion: '1',
}

in other component or service

import { environment } from '../../environments/environment';

environment.apiVersion