1Here is the simplest solution w/o Service nor Observer:
2
3Put the global variables in a file an export them.
4
5//
6// ===== File globals.ts
7//
8'use strict';
9
10export const sep='/';
11export const version: string="22.2.2";
12To use globals in another file use an import statement: import * as myGlobals from 'globals';
13
14Example:
15
16//
17// ===== File heroes.component.ts
18//
19import {Component, OnInit} from 'angular2/core';
20import {Router} from 'angular2/router';
21import {HeroService} from './hero.service';
22import {HeroDetailComponent} from './hero-detail.component';
23import {Hero} from './hero';
24import * as myGlobals from 'globals'; //<==== this one (**Updated**)
25
26export class HeroesComponent implements OnInit {
27 public heroes: Hero[];
28 public selectedHero: Hero;
29 //
30 //
31 // Here we access the global var reference.
32 //
33 public helloString: string="hello " + myGlobals.sep + " there";
34
35 ...
36
37 }
38 }
39Thanks @eric-martinez