3π
β
Yes you can. You either use arrow functions
DZ.Event.subscribe("track_end", (evt_name) => {
console.log("event fired 1");
//trying to access this bool var that is defined in data
this.isDeezerPlaying = false;
});
or you bind it:
DZ.Event.subscribe("track_end", function (evt_name) {
console.log("event fired 1");
//trying to access this bool var that is defined in data
this.isDeezerPlaying = false;
}.bind(this));
π€bill.gates
1π
try with below code:
const vm = this;
DZ.Event.subscribe("track_end", function (evt_name) {
console.log("event fired 1");
//trying to access this bool var that is defined in data
vm.isDeezerPlaying = false;
});
π€Jinal Somaiya
1π
Yes you can by using arrow functions :
DZ.Event.subscribe("track_end", (evt_name) => {
console.log("event fired 1");
this.isDeezerPlaying = false;
});
π€Pierre Said
Source:stackexchange.com