Hier ist mein Problem:nodejs: Wie kann ich ein globales Array füllen, das alle Objekte eines Typs enthält?
Ich habe eine Klasse Bot. Ich möchte es jedes Mal füllen, wenn ich ein Objekt dieser Klasse erstelle. Dann zeige es auf eine Jade-Datei. Bisher habe ich:
//bot.js
var listeBots = [];
exports.listeBots = listeBots;
// Constructeur
function Bot (nom, probavoyager, probatweet, probaretweet, nbhashtag, probalien, probalike, probamention, probaselfmention, visibilite,probaphoto) {
this.nom = nom;
this.probavoyager = probavoyager;
this.probatweet = probatweet;
this.probaretweet =probaretweet;
this.nbhashtag = nbhashtag;
this.probalien = probalien;
this.probalike = probalike;
this.probamention = probamention;
this.probaselfmention = probaselfmention;
this.visibilite = visibilite;
this.probaphoto = probaphoto;
}
exports.BotSuiveur = function(name){
Bot.call(this, name, 0.2, 0.2, 0.8, 1, 0.4, 0.8, 0.8, 0.2, 0.05, 0.1);
listeBots.push(this);
//console.log(this);
};
exports.BotLeader = function(name){
Bot.call(this, name, 0.2, 0.8, 0.4, 2, 0.6, 0.4, 0.4, 0.8, 0.8, 0.2);
listeBots.push(this);
//console.log(this);
};
function BotVoyageur() {
Bot.call(this, 0.8, 0.6, 0.4, 5, 0.4, 0.4, 0.4, 0.8, 0.15, 0.8);
//console.log(this);
}
// jade file
each kw in listeBots
li= kw
Meine Jade-Datei zeigt mir nur Object [Object] und so weiter Wie kann ich die Objekte in Jade sichtbar schätzen?
Vielen Dank im Voraus! Romain
warum Sie nicht iterieren und seine Werte anzeigen? –
was meinst du? Ich wiederhole es in meinem Jade-Code –
jeder kw in listeBots li = kw –