If two children components of the parent "app" component need access to such a variable, I would originally aspire to keep all logic relating to this variable under the parent component, hence 'app' in your case.
If for some reason it conflicts with the design of your app and you most have this variable under leftpanel component then ther are various solutions to this problem.
The easiest solution I see is to implement NgRedux and set it up in your project, by doing so you could dispatch an update to a certain state that holds record of this variable and gives easy access to it's value anywhere around your up easily bu subscribing to that certain state.
If you aren't famliar with NgRedux and want something less efficient but immediate you can do it the Angular way by importing these: Output, EventEmitter in your leftpanel comp, and emitting an event wherever neccesary(ngOnInit / on activation of a function, for example) and importing Input in your app component. Naturally the parent will listen to this event and upon triggering will activate a function that for now will just update a private variable in 'app' comp, like so:
import { Component, Output, EventEmitter } from '@angular/core';
@Component({
moduleId: module.id,
selector: 'letf-panel',
template: `
<div>Left Panel Content</div>
`
})
export class LeftPanelComponent {
@Output() timeEvent = new EventEmitter();
constructor() {}
}
And then under NgOnInit (Inside the LeftPanelComponent class) for example I emit the event with the time variable:
ngOnInit() {
this.timeEvent.emit(time)
}
You Input the event like so:
import { Component, Input } from '@angular/core';
@Component({
moduleId: module.id,
selector: 'app',
template: '<div (timeEvent)="getTime()"></div>',
})
export class AppComponent{
@Input() time:number;
private timeInApp;
getTime(timeFromLeftPanel) {
this.timeInApp = timeFromLeftPanel;
}
}
Once you have the variable in app comp you could Bind it to the workmat component like so:
[time]="time"
And in the template:
template: `<leftpanel #src></leftpanel><workmat [time]="time"></workmat>`
Let me know if this helps you with the problem