I'm trying to do this https://angular.io/docs/ts/latest/cookbook/component-communication.html#!#bidirectional-service
interaction.service.ts:
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs/Subject';    
import { Options } from './options';
@Injectable()
export class InteractionService {
    private optionsSource = new Subject<Options>();
    options$ = this.optionsSource.asObservable();
    setOptions(options: Options) {
        this.optionsSource.next(options);
    }
}
app.component.ts:
import { Component, OnInit } from '@angular/core';
import { CoreService } from './core/core.service';
import { InteractionService } from './providers/interaction.service';
import { Options } from './options';
@Component({
    selector: 'app',
    templateUrl: './app/app.component.html'
})
export class AppComponent implements OnInit {
    constructor(private coreService: CoreService,
        private interactionService: InteractionService) { }
    ngOnInit() {
          this.coreService.getOptions().subscribe((options: Options) => { 
              this.interactionService.setOptions(options);
            });
        }
    }
sidebar.component.ts:
import { Component, OnInit} from '@angular/core';
import { InteractionService } from './../../providers/interaction.service';
import { Options } from './options';
@Component({
    selector: 'app-sidebar',
    templateUrl: './app/core/sidebar/sidebar.component.html'
})
export class SidebarComponent implements OnInit {
    options: Options;
    constructor(private interactionService: InteractionService) {
        this.interactionService.options$.subscribe(
            (options: options) => {
                this.options = options;
            });
    }
    ngOnInit() {
        if (this.options.mode === "test") {
            //...
        } else {
            //...
        }
    }
}
app.component.html:
<app-sidebar></app-sidebar>
<router-outlet></router-outlet>
And declare "providers: [InteractionService]" in app.module.ts.
But in sidebar.component.ts I have error "Cannot read property 'mode' of undefined".
What do I do wrong? How can I resolve that?
 
     
    