One way to do it would be to make class with all the properties that you need and configure as a singleton when you bootstrap the application.
Service:
import {Injectable} from 'angular2/angular2';
@Injectable()
export class Config {
constructor() {}
public get USERID(): string {
return "XCAMPLISHIOUS";
}
}
Bootstraping:
import {bootstrap} from 'angular2/angular2';
import {TaciIlieApp} from './app/taci-ilie';
import {Config} from './app/services/config/config';
bootstrap(TaciIlieApp, [Config]); // configuring the Config provider here will ensure a single instance is created
Usage:
import {Component, Inject} from 'angular2/angular2';
import {Config} from '../../services/config/config';
@Component({
selector: 'game',
templateUrl: 'app/components/game/game.html',
styleUrls: ['app/components/game/game.css'],
providers: [],
directives: [],
})
export class Game {
constructor(private config: Config) {
console.log(this.config.USERID);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…