In my Angular 2 project I currently have an object called translation that contains a couple of strings that I use in some forms, it globally looks as follows:
public translator = {
'performance_standard_time_deviation': {
'both': 'Sentance A',
'shorter': 'Sentance B',
'longer': 'Sentance C',
'no': 'Sentance D'
},
'performance_soundcheck': {
2: 'Sentance A',
1: 'Sentance B',
0: 'Sentance C'
}
};
I need this object in a couple of components, currently I just copied the code and pasted it in each component, this obviously isn't a good solution since it violates the DRY rule. My question is as follows, what is the correct solution to share objects like these in an Angular 2 project? I know that you are able to pass variables from component to component, but that is a bit devious. What is the preferred way?