Reputation: 2893
I need to set application constants in my angular2 application , so that the things are available through out the entire application , in angular 1 i did with angular.constant and angular.value. I am looking for the best way here.
Upvotes: 3
Views: 3496
Reputation: 119
If you want to encapsulate them in a variable:
export const BaseConstants = Object.freeze({
BASE_API_URL: 'http://example.com/'
});
Upvotes: 3
Reputation: 657486
file constants.ts
export const XXX = 'yyy';
otherfile.ts
import {XXX} from 'constants.ts'
Upvotes: 5