如何在MeanJS中启用和使用'_'?

如何在MeanJS中启用和使用'_'?

问题描述:

我试图从服务器上的猫鼬模型内使用lodash,_.pluck(...),并且我收到“ReferenceError:_ is not defined”。如何在MeanJS中启用和使用'_'?

从我读到的,lodash包含在MeanJS。我需要做些什么特别的事吗?

想必您需要它就像其他任何模块一样。我searched for "lodash" in the MEAN.JS source和这个来了几次:

var _ = require('lodash'); 

给它一个镜头。

它默认包含在MEAN.JS项目中。生成示例应用程序并查看使用示例。

var mongoose = require('mongoose'), 
    Article = mongoose.model('Article'), 
    _ = require('lodash');`