如何将我的产品资源实现为 Pods 结构?

How to implement my product resource into a Pods structure?

阅读http://www.ember-cli.com/#pod-structure

假设我有一个产品资源。当前具有以下目录结构:

app/controllers/products/base.js
app/controllers/products/edit.js
app/controllers/products/new.js
app/controllers/products/index.js

使用 pods 这些文件中的所有逻辑都放在一个文件中 app/products/controller.js?

同时,我的这些资源的 routestemplates 目前看起来像:

app/routes/products/base.js
app/routes/products/edit.js
app/routes/products/new.js
app/routes/products/index.js
app/templates/products/-form.hbs
app/templates/products/edit.hbs
app/templates/products/index.hbs
app/templates/products/new.hbs
app/templates/products/show.hbs

如何转换为Pods?

您可以使用 ember generate --pod --dry-run 来帮助解决这个问题:

$ ember g -p -d route products/base
version: 0.1.6
The option '--dryRun' is not supported by the generate command. Run `ember generate --help` for a list of supported options.
installing
You specified the dry-run flag, so no changes will be written.
  create app/products/base/route.js
  create app/products/base/template.hbs
installing
You specified the dry-run flag, so no changes will be written.
  create tests/unit/products/base/route-test.js
$

(我不知道它为什么抱怨但它尊重这个选项,可能是一个错误)。

所以你最终会得到这样的结构:

app/controllers/products/base/route.js
app/controllers/products/edit/route.js

等等