Tôi có một đối tượng đơn giản theo nghĩa đen mà là địa chỉ như đâyEJS làm thế nào để lặp đối tượng
address: {
country: String,
state: String,
city: String,
zip: String,
street: String
}
và nó bên trong một đối tượng mà tôi đang đi với express.js chức năng render.
trong trang mẫu của tôi, tôi đang cố gắng để cho vòng lặp bên trong đối tượng này như:
<% for (var prop in artist.address) { %>
<%- artist.address[prop] %>
<% } %>
đó sản lượng dữ liệu nhưng bao gồm các chức năng EJS cũng như vậy:
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 ===
nên làm thế nào để tôi cần phải lặp lại đối tượng của tôi?
câu trả lời tốt ở đây: http://stackoverflow.com/questions/14379274/javascript-iterate-object – snozza
là 'địa chỉ 'thực sự là một' mongoose.Schema' và 'artist.address' là một' mongoose.Document'? – mscdex
không, nghệ sĩ là một nghệ sĩ mongoose.schema varSchema = mongoose.Schema ({ địa chỉ: { nước: String, nhà nước: String, thành phố: String, zip: String, đường phố: String }, .... –