I have two service (A and B) communicating between each others, A has to build a chart when the other one received asynchronous datas (those datas are used somewhere else, so B is independant). I've tried to shift what I do with the component A into its service but it looks like I cant get access to the template of the component :
@Injectable()
export class HistoricGraphService {
... // doing stuff
onNewData() {
const canvas = <HTMLCanvasElement>document.getElementById('historic-chart');
const ctx = canvas.getContext('2d');
... building the chart based on datas, timestamp and much more
}
}
The problem isnt around the datas, making the chart works when this method is used in Component A, I'd just like to understand why I cant use that same process to get an Element from my template.