用MeanJS和Yeoman生成器生成【翻译】

技术分享

One of my favorite things with Yii is the Gii (Generator).

关于Yii(php框架)我喜爱的事情之一是Gii(生成器)Global Information Infrastructure。

 

With a few clicks I could simply add a few Models/Controllers/Views (or all of the above), then build/customize those.

我只需要点击几次就可以添加一些模型/控制器/视图(或者这三个一起),然后就可以构建/定制他们了。

 

MeanJS uses the Yeoman/Yo generator to make this happen. After installing Yeoman generator (which I believe we already installed when we installed MeanJS) via:

 MeanJS 使用Yeoman/Yo生成器让这个变为可能。安装了Yeoman生成器之后(我相信在我们安装MeanJs的时候我们已经安装了) 通过:

npm install -g yo
Now to install the MeanJS generator package:
现在开始安装MeanJs生成器的包:
npm install -g generator-meanjs

(remember, often when running npm install -g you’ll need to sudo it)

(记住,当执行npm install -g 命令的时候,经常你需要用sudo提升权限来执行(linux里的命令))

Basic CRUD

基本的增读改删

For those who are not familiar with the concept, CRUD stands for – Create, Read, Update & Delete.

 

These are the basics one needs to present & manipulate data on a website, and a lot of web frameworks generate CRUDs as sort of a first-step.

Let’s create our first CRUD:

yo meanjs:crud-module firstmodule

After selecting the supplemental folder to include in the Angular Module, and whether or not the module should be added to the menu, a bunch of files are generated.

Very Important: The crud-module generates both the Server side & Client files.

The Module Structure was explained thoroughly onBasics of MeanJS.

The crud-module is the all encompassing, there are also sub generators:

  • angular-module
  • angular-route
  • angular-controller
  • angular-view
  • angular-service
  • angular-directive
  • angular-filter
  • angular-config
  • angular-test
  • express-model
  • express-controller
  • express-route
  • express-test

Those names are pretty self explanatory, so I don’t see much need to go deeper there.

More information about Yeoman generator specifically used for MeanJS can be foundhere

As you can probably notice, this article came out a bit shorter than expected, this is mainly due to time constraints.

I’d like to continue and develop under MeanJS, as I see a lot of interest on the subject.

There are also a few other frameworks that I started reading about that might be a part of some future articles (some are fairly similar).

Bonus info: MeanJS was on the Changelog podcast! , very cool.

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。