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
  • 7,766
  • 8
  • 46
  • 61
Anand agrawal
  • 462
  • 5
  • 24

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