im creating comments system , im trying add values view such text, username, timeposted , userprofileimageurl 1 wont appear userprofileimageurl.
i think problem controller function somewhere else altogether.
/** * comment middleware */ exports.commentbyid = function (req, res, next, id) { comment.findbyid(id).populate('user', 'displayname').exec(function (err, comment) { if (err) return next(err); if (!comment) return next(new error('failed load comment ' + id)); req.comment = comment; next(); }); };
or here possibly
/** * list of comments */ exports.list = function (req, res) { var id = req.dealid; console.log('log - ' + id); comment.find( ) .sort('-created') .populate('user', 'displayname') .exec(function (err, comments) { if (err) { return res.status(400).send({ message: errorhandler.geterrormessage(err) }); } else { res.jsonp(comments); } }); };
what 'user' , 'displayname' parameter in function do?
can add 'userprofileimageurl' returned data somehow?
im using profileimageurl value this. display name showing not profileimageurl
<img ng-src="{{post.user.profileimageurl}}" alt="{{post.user.displayname}}" />
/** * list of comments */ exports.list = function (req, res) { var id = req.dealid; console.log('log - ' + id); comment.find( ) .sort('-created') .populate('user') .exec(function (err, comments) { if (err) { return res.status(400).send({ message: errorhandler.geterrormessage(err) }); } else { res.jsonp(comments); } }); };
just have delete displayname parameter , send whole user object.
Comments
Post a Comment