How to change the behavior of `this' in the below code. Currently, it is pointing to a click event on the HighChart. I want `this` here to refer to function in the class.
Hello.ts
getPlotBands() {
.....
click: function(e) {
for(var p = 0; p < this.axis.plotLinesAndBands.length; p++) {
var currentPlotBand = this.axis.plotLinesAndBands[p];
currentPlotBand.svgElem.attr({fill: currentPlotBand.options.color});
}
this.svgElem.attr({fill:'#660066'});
// this.fromSystemTime = String(new Date(this.options.from));
this.fromSystemTime = moment(this.options.from).format("MM/DD/YY h:mm:ss");
this.toSystemTime = String(new Date(this.options.to));
console.log(moment(this.options.from).format("MM/DD/YY h:mm:ss"));
(<HTMLInputElement>document.getElementById('fromSys')).value =
moment(this.options.from).zone("America/Los_Angeles").format('MM/DD/YY HH:mm');
(<HTMLInputElement>document.getElementById('toSys')).value =
moment(this.options.to).zone("America/Los_Angeles").format('MM/DD/YY HH:mm');
console.log('to date -', moment(1556906400000).utcOffset(-420).format('MM/DD/YY HH:mm'));
console.log(moment(1556906400000).zone("America/Los_Angeles").format('MM/DD/YY HH:mm'));
// console.log('from', this.options.from);
// console.log('to', this.options.to);
console.log(this.options.from + 'and' + this.options.to)
tagStartTimeForDetailsPage = +moment(this.options.from);
tagEndTimeForDetailsPage = +moment(this.options.to);
` this.storedResponse.setTagStartTimeForDetailsPage(+tagStartTimeForDetailsPage);
this.storedResponse.setTagEndTimeForDetailsPage(+tagEndTimeForDetailsPage);
}` }
I want here `this' to refer my storedResponse service injected in the class not chart obj.
The below 2 lines are giving the error
`this.storedResponse.setTagStartTimeForDetailsPage(+tagStartTimeForDetailsPage);
this.storedResponse.setTagEndTimeForDetailsPage(+tagEndTimeForDetailsPage); `
The above code is there inside Hello.Ts file having 1 method called getplotBands().so here i need to change the context of this.
any idea how to get it done?