Prezados,
O código abaixo esta funcionando.
Mas quando tento usar o this.dashboardView dentro de um método sem armazena-lo em uma variável, da um erro dizendo que a propriedade não pode ser lida.
"Cannot read property 'dashboardView' of undefined"
Sou novato em OO e ainda estou perdido nos conceitos.
class DashboardController {
constructor () {
this.dashboardView = new DashboardView("#grid-dashboard");
}
clearData () {
let dashboardView = this.dashboardView;
dashboardView.clear();
}
getData (nodes) {
let dashboardView = this.dashboardView;
nodes.map(function(n) {
var url = `http://${n.Node}:3000/services`;
var xhr = new XMLHttpRequest();
xhr.open("GET", url);
xhr.addEventListener("load", function() {
var json = xhr.responseText;
var services = JSON.parse(json);
services.forEach(function(service) {
if (!service.Status) {
dashboardView.create(n.Node, service.Name);
}
});
});
xhr.send();
});
}
}