pug

Model.find().toArray() claiming to not have .toArray() method

梦想的初衷 提交于 2019-11-26 17:51:35
I am very new to nodejs and mongodb and am trying to piece together my own blogging application. I have a problem trying to query through my 'Blog' model for ones with a specific username. When I try to run var userBlogs = function(username) { ub = Blog.find({author: username}).toArray(); ub = ub.reverse(); }; I get an error. TypeError: Object #<Query> has no method 'toArray' I know globals are bad but I've just been trying to get it to work. The Mongo documentation claims that a cursor is returned which can have the toArray() method called on it. I have no idea why it won't work. Here is my

Angular 4: InvalidPipeArgument: '[object Object]' for pipe 'AsyncPipe'

╄→гoц情女王★ 提交于 2019-11-26 16:04:59
问题 i need your help, i'm trying to display some datas from my firebase but it trhows me an error like InvalidPipeArgument: '[object Object]' for pipe 'AsyncPipe' . There is my service: import { Injectable } from '@angular/core'; import { AngularFireDatabase } from 'angularfire2/database'; @Injectable() export class MoviesService { constructor(private db: AngularFireDatabase) {} get = () => this.db.list('/movies'); } There is my component: import { Component, OnInit } from '@angular/core'; import

Loop in Jade (currently known as “Pug”) template engine

点点圈 提交于 2019-11-26 10:34:34
问题 I want to use a simple loop like for(int i=0; i<10; i++){} . How do I use it in the Jade engine? I\'m working with Node.js and use the expressjs framework. 回答1: for example: - for (var i = 0; i < 10; ++i) { li= array[i] - } you may see https://github.com/visionmedia/jade for detailed document. 回答2: Using node I have a collection of stuff @stuff and access it like this: - each stuff in stuffs p = stuff.sentence 回答3: An unusual but pretty way of doing it Without index : each _ in Array(5) = 'a'

Change the “No file chosen”:

喜夏-厌秋 提交于 2019-11-26 10:27:32
问题 I have a button \"Choose file\" as follows (I am using Jade but it should be the same as Html5): input(type=\'file\', name=\'videoFile\') In the browser this shows a button with a text next to it \"No file chosen\". I would like to change the \"No file chosen\" text to something else, like \"No video chosen\" or \"Choose a video please\". I followed the first suggestions here: I don't want to see 'no file chosen' for a file input field But doing this did not change the text: input(type=\'file

Use a variable in a Jade include

雨燕双飞 提交于 2019-11-26 07:27:23
问题 I\'m working with Jade and Express and I would like to use a variable in my include statement. For example: app.js app.get(\'/admin\', function (req, res) { var Admin = require(\'./routes/admin/app\').Admin; res.render(Admin.view, { title: \'Admin\', page: \'admin\' }); }); layout.jade - var templates = page + \'/templates/\' include templates When I do this I get the error EBADF, Bad file descriptor \'templates.jade\' I even tried include #{templates} to no avail. 回答1: AFAIK JADE does not

How to pass variable from jade template file to a script file?

大憨熊 提交于 2019-11-26 06:57:28
问题 I\'m having trouble with a variable (config) declared in a jade template file (index.jade) that isn\'t passed to a javascript file, which then makes my javascript crash. Here is the file (views/index.jade): h1 #{title} script(src=\'./socket.io/socket.io.js\') script(type=\'text/javascript\') var config = {}; config.address = \'#{address}\'; config.port = \'#{port}\'; script(src=\'./javascripts/app.js\') Here is a part of my app.js (server side): app.use(express.bodyParser()); app.use(express

Model.find().toArray() claiming to not have .toArray() method

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 05:38:15
问题 I am very new to Node.js and MongoDB and am trying to piece together my own blogging application. I have a problem trying to query through my \'Blog\' model for ones with a specific username. When I try to run: var userBlogs = function(username) { ub = Blog.find({author: username}).toArray(); ub = ub.reverse(); }; I get an error: TypeError: Object #<Query> has no method \'toArray\' I know globals are bad but I\'ve just been trying to get it to work. The Mongo documentation claims that a

Accessing Express.js local variables in client side JavaScript

*爱你&永不变心* 提交于 2019-11-26 05:19:25
问题 Curious if I\'m doing this right and if not how you guys would approach this. I have a Jade template that needs to render some data retrieved from a MongoDB database and I also need to have access to that data inside a client side JavaScript file. I\'m using Express.js and sending the data to the Jade template as follows : var myMongoDbObject = {name : \'stephen\'}; res.render(\'home\', { locals: { data : myMongoDbObject } }); Then inside of home.jade I can do things like : p Hello #{data

Client on node: Uncaught ReferenceError: require is not defined

旧时模样 提交于 2019-11-25 21:55:45
问题 So, I am writing an application with the node/express + jade combo. I have client.js , which is loaded on the client. In that file I have code that calls functions from other JavaScript files. My attempt was to use var m = require(\'./messages\'); in order to load the contents of messages.js (just like I do on the server side) and later on call functions from that file. However, require is not defined on the client side, and it throws an error of the form Uncaught ReferenceError: require is