Ho un semplice oggetto letterale che è l'indirizzo come qui mostratoejs come iterare oggetto
address: {
country: String,
state: String,
city: String,
zip: String,
street: String
}
ed il suo interno un oggetto che sto passando con express.js funzione rendering.
nel mio modello di pagina che sto cercando di ciclo for all'interno di questo oggetto, come mostrato:
<% for (var prop in artist.address) { %>
<%- artist.address[prop] %>
<% } %>
che l'output dei dati, ma include le funzioni EJS così in questo modo:
function() { return this.get(path); } function() { return this.get(path); } yafo 09988 jerusalem israel israeli [object Object] undefined undefined undefined undefined undefined undefined undefined undefined undefined undefined undefined undefined undefined undefined [object Object] [object Object] function() { var self = this , hookArgs // arguments eventually passed to the hook - are mutable , lastArg = arguments[arguments.length-1] , pres = this._pres[name] , posts = this._posts[name] , _total = pres.length , _current = -1 , _asyncsLeft = proto[name].numAsyncPres , _next = function() { if (arguments[0] instanceof Error) { return handleError(arguments[0]); } var _args = Array.prototype.slice.call(arguments) , currPre , preArgs; if (_args.length && !(arguments[0] == null && typeof lastArg ===
così come ho bisogno di iterare il mio oggetto?
buona risposta qui: http://stackoverflow.com/questions/14379274/javascript-iterate-object – snozza
è 'indirizzo 'in realtà un' mongoose.Schema' e 'artist.address' è un' mongoose.Document'? – mscdex
no, l'artista è un mongoose.schema var artistSchema = mangusta.Schema ({ indirizzo: { Paese: String, state: String, città: String, zip: String, strada: String }, .... –